Skip to content

Commit

Permalink
mingw: support waitpid with pid > 0 and WNOHANG
Browse files Browse the repository at this point in the history
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Erik Faye-Lund authored and Junio C Hamano committed Nov 4, 2010
1 parent 52de4db commit ef7108c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions compat/mingw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions compat/mingw.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ static inline int mingw_unlink(const char *pathname)
}
#define unlink mingw_unlink

#define WNOHANG 1
pid_t waitpid(pid_t pid, int *status, unsigned options);

#ifndef NO_OPENSSL
Expand Down

0 comments on commit ef7108c

Please sign in to comment.