[dev] [st] [PATCH] Fix sigchld

From: Jochen Sprickerhof <dwm_AT_jochen.sprickerhof.de>
Date: Wed, 22 Apr 2015 17:22:34 +0200

Only wait for termination of the shell.
---
 st.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/st.c b/st.c
index 0204b2e..1615609 100644
--- a/st.c
+++ b/st.c
_AT_@ -1245,10 +1245,14 @@ execsh(void) {
 void
 sigchld(int a) {
 	int stat, ret;
+	pid_t p;
 
-	if(waitpid(pid, &stat, 0) < 0)
+	if((p = waitpid(pid, &stat, WNOHANG)) < 0)
 		die("Waiting for pid %hd failed: %s\n", pid, strerror(errno));
 
+	if(pid != p)
+		return;
+
 	ret = WIFEXITED(stat) ? WEXITSTATUS(stat) : EXIT_FAILURE;
 	if (ret != EXIT_SUCCESS)
 		die("child finished with error '%d'\n", stat);
-- 
2.1.4

Received on Wed Apr 22 2015 - 17:22:34 CEST

This archive was generated by hypermail 2.3.0 : Wed Apr 22 2015 - 17:24:08 CEST