From 88b8cb61e8fb1db9026518c2302331b30146b9f2 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Fri, 3 May 2013 10:48:22 +0100 Subject: ash: Add a very small timeout to nonblocking wait A nonblocking waitpid was implemented using WaitForMultipleObjects with a timeout of 0. This was to fix an issue where builtin commands in a foreground shell were blocked while a background command was running. However, this caused the shell to consume 100% CPU. A workaround seems to be to use a very small (1ms) timeout. --- shell/ash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'shell') diff --git a/shell/ash.c b/shell/ash.c index e7a0e5dc5..80a85b9eb 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -4153,7 +4153,7 @@ waitpid_child(int *status, int wait_flags) #undef LOOP idx = WaitForMultipleObjects(pid_nr, pidlist, FALSE, - wait_flags|WNOHANG ? 0 : INFINITE); + wait_flags|WNOHANG ? 1 : INFINITE); if (idx >= pid_nr) { free(pidlist); return -1; -- cgit v1.2.3-55-g6feb