From: simonmar Date: Mon, 7 Mar 2005 10:40:44 +0000 (+0000) Subject: [project @ 2005-03-07 10:40:44 by simonmar] X-Git-Tag: nhc98-1-18-release~4 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=32d696aff631005a142dee44387f002fedf40d3e;hp=d98bd1c893b597a0748dc863b70ee186b5991186;p=ghc-base.git [project @ 2005-03-07 10:40:44 by simonmar] merge rev. 1.4.2.1 to HEAD --- diff --git a/cbits/runProcess.c b/cbits/runProcess.c index 8358605..82fa97e 100644 --- a/cbits/runProcess.c +++ b/cbits/runProcess.c @@ -153,11 +153,11 @@ terminateProcess (ProcHandle handle) int getProcessExitCode (ProcHandle handle, int *pExitCode) { - int wstat; + int wstat, res; *pExitCode = 0; - if (waitpid(handle, &wstat, WNOHANG) > 0) + if ((res = waitpid(handle, &wstat, WNOHANG)) > 0) { if (WIFEXITED(wstat)) { @@ -176,7 +176,15 @@ getProcessExitCode (ProcHandle handle, int *pExitCode) } } - return 0; + if (res == 0) return 0; + + if (errno == ECHILD) + { + *pExitCode = 0; + return 1; + } + + return -1; } int waitForProcess (ProcHandle handle)