From 4d8a277d59ad9c4036c9c595e0647a900f6bd7c8 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Tue, 14 Feb 2012 16:16:16 +0000 Subject: Implement nonblocking wait --- shell/ash.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/shell/ash.c b/shell/ash.c index de1116656..1061e55c2 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -4079,7 +4079,7 @@ static BOOL WINAPI ctrl_handler(DWORD dwCtrlType) * They don't support waitpid(-1) */ static pid_t -waitpid_child(int *status) +waitpid_child(int *status, int wait_flags) { HANDLE *pidlist, *pidp; int pid_nr = 0; @@ -4111,7 +4111,8 @@ waitpid_child(int *status) LOOP(*pidp++ = (HANDLE)ps->ps_pid); #undef LOOP - idx = WaitForMultipleObjects(pid_nr, pidlist, FALSE, INFINITE); + idx = WaitForMultipleObjects(pid_nr, pidlist, FALSE, + wait_flags|WNOHANG ? 0 : INFINITE); if (idx >= pid_nr) { free(pidlist); return -1; @@ -4150,7 +4151,7 @@ dowait(int wait_flags, struct job *job) if (doing_jobctl) wait_flags |= WUNTRACED; #if ENABLE_PLATFORM_MINGW32 - pid = waitpid_child(&status); + pid = waitpid_child(&status, wait_flags); #else pid = waitpid(-1, &status, wait_flags); #endif -- cgit v1.2.3-55-g6feb