[PATCH v2 05/14] mingw: support waitpid with pid > 0 and WNOHANG
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
---
compat/mingw.h | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/compat/mingw.h b/compat/mingw.h
index d934e56..3005472 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -134,8 +134,15 @@ static inline int mingw_unlink(const char *pathname)
}
#define unlink mingw_unlink
+#define WNOHANG 1
static inline int waitpid(pid_t pid, int *status, unsigned options)
{
+ if (pid > 0 && options & WNOHANG) {
+ if (WAIT_OBJECT_0 != WaitForSingleObject((HANDLE)pid, 0))
+ return 0;
+ options &= ~WNOHANG;
+ }
+
if (options == 0)
return _cwait(status, pid, 0);
errno = EINVAL;
--
1.6.6.211.g26720