From 988683c57279eca5a43720826ec2a5a481412a85 Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Fri, 16 Jan 2015 18:14:55 -0600 Subject: [PATCH] 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. --- shell/hush.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/shell/hush.c b/shell/hush.c index 682989f4b..fc1d2de35 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -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! */