Fix "wait" builtin to work correctly in no-parameters case

This was another issue where wait() was being called with SIGCHLD masked, and therefore never returning.
This commit is contained in:
Stephen Heumann 2015-01-16 18:14:55 -06:00
parent d305e3b821
commit 988683c572

View File

@ -9805,6 +9805,11 @@ static int FAST_FUNC builtin_wait(char **argv)
* signals which we use. Thus, this ugly dance:
*/
checkjobs(NULL); /* waitpid(WNOHANG) inside */
if (errno == ECHILD) {
break;
}
/* Make sure possible SIGCHLD is stored in kernel's
* pending signal mask before we call waitpid.
* Or else we may race with SIGCHLD, lose it,
@ -9830,12 +9835,6 @@ static int FAST_FUNC builtin_wait(char **argv)
} while (sig < NSIG);
#endif
checkjobs(NULL); /* waitpid(WNOHANG) inside */
if (errno == ECHILD) {
sigprocmask(SIG_SETMASK, &oldset, NULL);
break;
}
/* Wait for SIGCHLD or any other signal */
//sig = sigwaitinfo(&allsigs, NULL);
/* It is vitally important for sigsuspend that SIGCHLD has non-DFL handler! */