aboutsummaryrefslogtreecommitdiffstats
path: root/src/system-w32.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/system-w32.c')
-rw-r--r--src/system-w32.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/system-w32.c b/src/system-w32.c
index 415cd63..a1ac42f 100644
--- a/src/system-w32.c
+++ b/src/system-w32.c
@@ -598,8 +598,30 @@ assuan_pid_t
__assuan_waitpid (assuan_context_t ctx, assuan_pid_t pid, int nowait,
int *status, int options)
{
- CloseHandle ((HANDLE) pid);
- return 0;
+ int code;
+ DWORD exit_code;
+
+ (void)ctx;
+
+ if (nowait)
+ return 0;
+
+ code = WaitForSingleObject ((HANDLE)pid, options? 0: INFINITE);
+
+ if (code == WAIT_OBJECT_0)
+ {
+ if (status)
+ {
+ GetExitCodeProcess ((HANDLE)pid, &exit_code);
+ *status = (int)exit_code;
+ }
+ CloseHandle ((HANDLE)pid);
+ return pid;
+ }
+ else if (code == WAIT_TIMEOUT)
+ return 0;
+ else
+ return -1;
}