Thread (21 messages) flat view 21 messages, 3 authors, 2016-06-15
STALE3746d

Revision v7 of 5 in this series.

Revisions (5)
  1. v3 [diff vs current]
  2. v4 [diff vs current]
  3. v5 [diff vs current]
  4. v6 [diff vs current]
  5. v7 current

[PATCH v7 06/16] mingw: support waitpid with pid > 0 and WNOHANG

From: Erik Faye-Lund <hidden>
Date: 2016-06-15 22:49:58
Subsystem: the rest · Maintainer: Linus Torvalds

Signed-off-by: Erik Faye-Lund <redacted>
---
 compat/mingw.c |    8 ++++++++
 compat/mingw.h |    1 +
 2 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/compat/mingw.c b/compat/mingw.c
index 736d03f..47a0e88 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -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) {
diff --git a/compat/mingw.h b/compat/mingw.h
index 7c4eeea..379d7bf 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -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
-- 
1.7.3.2.162.g09d37
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help