Browse Source

Fix sigchld

Only wait for termination of the shell.
master
Jochen Sprickerhof 9 years ago
committed by Roberto E. Vargas Caballero
parent
commit
07ce96a3a0
1 changed files with 5 additions and 1 deletions
  1. +5
    -1
      st.c

+ 5
- 1
st.c View File

@ -1238,10 +1238,14 @@ execsh(void) {
void void
sigchld(int a) { sigchld(int a) {
int stat, ret; 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)); die("Waiting for pid %hd failed: %s\n", pid, strerror(errno));
if(pid != p)
return;
ret = WIFEXITED(stat) ? WEXITSTATUS(stat) : EXIT_FAILURE; ret = WIFEXITED(stat) ? WEXITSTATUS(stat) : EXIT_FAILURE;
if (ret != EXIT_SUCCESS) if (ret != EXIT_SUCCESS)
die("child finished with error '%d'\n", stat); die("child finished with error '%d'\n", stat);


Loading…
Cancel
Save