on windows, the return values from wait() and waitpid() don't
[p5sagit/p5-mst-13.2.git] / win32 / win32.c
index 3c3d1e5..56ebdaf 100644 (file)
@@ -1654,7 +1654,7 @@ win32_waitpid(int pid, int *status, int flags)
                    *status = (int)((waitcode & 0xff) << 8);
                    retval = (int)w32_pseudo_child_pids[child];
                    remove_dead_pseudo_process(child);
-                   return retval;
+                   return -retval;
                }
            }
            else
@@ -1666,20 +1666,19 @@ win32_waitpid(int pid, int *status, int flags)
        long child = find_pid(pid);
        if (child >= 0) {
            HANDLE hProcess = w32_child_handles[child];
-                DWORD timeout=(flags&WNOHANG)?0:INFINITE;
-                DWORD waitcode = WaitForSingleObject(hProcess, timeout);
-                if (waitcode == WAIT_TIMEOUT) {
-                {
-                       return 0;
-                }
-                else if (waitcode != WAIT_FAILED) {
-                    if (GetExitCodeProcess(hProcess, &waitcode)) {
-                        *status = (int)((waitcode & 0xff) << 8);
-                        retval = (int)w32_child_pids[child];
-                        remove_dead_process(child);
-                        return retval;
-                    }
+           DWORD timeout = (flags & WNOHANG) ? 0 : INFINITE;
+           DWORD waitcode = WaitForSingleObject(hProcess, timeout);
+           if (waitcode == WAIT_TIMEOUT) {
+               return 0;
+           }
+           else if (waitcode != WAIT_FAILED) {
+                if (GetExitCodeProcess(hProcess, &waitcode)) {
+                    *status = (int)((waitcode & 0xff) << 8);
+                    retval = (int)w32_child_pids[child];
+                    remove_dead_process(child);
+                    return retval;
                 }
+           }
            else
                errno = ECHILD;
        }
@@ -1721,7 +1720,7 @@ win32_wait(int *status)
                *status = (int)((exitcode & 0xff) << 8);
                retval = (int)w32_pseudo_child_pids[i];
                remove_dead_pseudo_process(i);
-               return retval;
+               return -retval;
            }
        }
     }