diff options
author | Jochen Sprickerhof | 2015-04-22 17:22:34 +0200 |
---|---|---|
committer | Roberto E. Vargas Caballero | 2015-05-04 10:57:40 +0200 |
commit | 07ce96a3a0f4a650933f5f586082cbf2064ea2c1 (patch) | |
tree | 8d1bf87de67d6cd4f80a9461cefabc0bc55a2882 | |
parent | 190b94c7a2a7bb2f5d55cbb6eb1779fd042c6467 (diff) | |
download | st-07ce96a3a0f4a650933f5f586082cbf2064ea2c1.tar.gz st-07ce96a3a0f4a650933f5f586082cbf2064ea2c1.tar.xz st-07ce96a3a0f4a650933f5f586082cbf2064ea2c1.zip |
Fix sigchld
Only wait for termination of the shell.
-rw-r--r-- | st.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -1238,10 +1238,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); |