From 0711c1f4eda3f10d8295ca0d9eb50e1a380baa86 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Wed, 27 May 2015 15:05:11 +0100 Subject: win32: fix waitpid implementation _cwait requires a process handle, not a pid. --- win32/process.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/win32/process.c b/win32/process.c index 462731a2d..dc9e98305 100644 --- a/win32/process.c +++ b/win32/process.c @@ -3,9 +3,18 @@ int waitpid(pid_t pid, int *status, unsigned options) { + HANDLE proc; + int ret; + /* Windows does not understand parent-child */ - if (options == 0 && pid != -1) - return _cwait(status, pid, 0); + if (options == 0 && pid != -1) { + if ( (proc=OpenProcess(SYNCHRONIZE|PROCESS_QUERY_INFORMATION, + FALSE, pid)) != NULL ) { + ret = _cwait(status, proc, 0); + CloseHandle(proc); + return ret; + } + } errno = EINVAL; return -1; } -- cgit v1.2.3-55-g6feb