[hackers] [st][PATCH] Inhibited st from reporting I/O error when process dies

From: Philip K <philippija_AT_googlemail.com>
Date: Sun, 13 May 2018 18:57:23 +0200

---
 st.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/st.c b/st.c
index 0628707..d5cfd74 100644
--- a/st.c
+++ b/st.c
_AT_@ -824,10 +824,15 @@ ttyread(void)
 	static int buflen = 0;
 	int written;
 	int ret;
+	pid_t ret_pid;
 
 	/* append read bytes to unprocessed bytes */
-	if ((ret = read(cmdfd, buf+buflen, LEN(buf)-buflen)) < 0)
-		die("couldn't read from shell: %s\n", strerror(errno));
+	if ((ret = read(cmdfd, buf+buflen, LEN(buf)-buflen)) < 0) {
+		 ret_pid = waitpid(pid, NULL, WNOHANG);
+		 if (ret_pid == pid) /* child is dead */
+			  exit(EXIT_SUCCESS);
+		 else die("couldn't read from shell: %s\n", strerror(errno));
+	}
 	buflen += ret;
 
 	written = twrite(buf, buflen, 0);
-- 
2.17.0
Received on Sun May 13 2018 - 18:57:23 CEST

This archive was generated by hypermail 2.3.0 : Sun May 13 2018 - 19:24:24 CEST