X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=cbits%2FrunProcess.c;h=82fa97e594f8f3e761a30ba82b8e0e79ac4b68de;hb=32d696aff631005a142dee44387f002fedf40d3e;hp=83586056f6ccf2ffc18942f842a7b7f87b02438a;hpb=d98bd1c893b597a0748dc863b70ee186b5991186;p=ghc-base.git 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)