[project @ 2005-03-07 10:40:44 by simonmar]
authorsimonmar <unknown>
Mon, 7 Mar 2005 10:40:44 +0000 (10:40 +0000)
committersimonmar <unknown>
Mon, 7 Mar 2005 10:40:44 +0000 (10:40 +0000)
merge rev. 1.4.2.1 to HEAD

cbits/runProcess.c

index 8358605..82fa97e 100644 (file)
@@ -153,11 +153,11 @@ terminateProcess (ProcHandle handle)
 int\r
 getProcessExitCode (ProcHandle handle, int *pExitCode)\r
 {\r
-    int wstat;\r
+    int wstat, res;\r
     \r
     *pExitCode = 0;\r
     \r
-    if (waitpid(handle, &wstat, WNOHANG) > 0)\r
+    if ((res = waitpid(handle, &wstat, WNOHANG)) > 0)\r
     {\r
        if (WIFEXITED(wstat))\r
        {\r
@@ -176,7 +176,15 @@ getProcessExitCode (ProcHandle handle, int *pExitCode)
            }\r
     }\r
     \r
-    return 0;\r
+    if (res == 0) return 0;\r
+\r
+    if (errno == ECHILD) \r
+    {\r
+           *pExitCode = 0;\r
+           return 1;\r
+    }\r
+\r
+    return -1;\r
 }\r
 \r
 int waitForProcess (ProcHandle handle)\r