mingw: support waitpid with pid > 0 and WNOHANG
[gitweb.git] / compat / mingw.c
index 736d03fa0c3b61163325d9ef6933111e4ef2e656..47a0e8861dd5d55a77b3476119ee5504fc922126 100644 (file)
@@ -1554,6 +1554,14 @@ pid_t waitpid(pid_t pid, int *status, unsigned options)
                return -1;
        }
 
+       if (pid > 0 && options & WNOHANG) {
+               if (WAIT_OBJECT_0 != WaitForSingleObject(h, 0)) {
+                       CloseHandle(h);
+                       return 0;
+               }
+               options &= ~WNOHANG;
+       }
+
        if (options == 0) {
                struct pinfo_t **ppinfo;
                if (WaitForSingleObject(h, INFINITE) != WAIT_OBJECT_0) {