From 3bccb33ccd9028ff505d9979fd6c8a37393b892d Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Thu, 25 May 2023 13:49:09 +0900 Subject: Add new pipe functions to control its server process. * src/assuan-pipe-connect.c (assuan_pipe_wait_server_termination) (assuan_pipe_kill_server): New. * src/assuan.h.in: Add new functions. * src/libassuan.def: Add symbols for those functions. * src/libassuan.vers: Likewise. * src/system-posix.c (__assuan_waitpid): Extend the semantics for OPTIONS. * src/system-w32.c (__assuan_waitpid): Likewise. -- GnuPG-bug-id: 6487 Signed-off-by: NIIBE Yutaka --- src/system-w32.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'src/system-w32.c') 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; } -- cgit v1.2.3