From bc0c61a40a5c68c1fbefc475735e88788e6b1bc4 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 23 Jun 2012 22:29:39 +0000 Subject: [PATCH] -LRN: Better process termination for W32: Avoids spewing warnings about killing processes that are already dead. Also removes a FIXME. --- src/util/os_priority.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/util/os_priority.c b/src/util/os_priority.c index 3f49290a7..c9174dee9 100644 --- a/src/util/os_priority.c +++ b/src/util/os_priority.c @@ -455,10 +455,17 @@ GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc, int sig) case SIGKILL: case SIGTERM: #if WINDOWS && !defined(__CYGWIN__) - if (0 == TerminateProcess (proc->handle, 0)) { - /* FIXME: set 'errno' */ - return -1; + DWORD exitcode; + int must_kill = GNUNET_YES; + if (0 != GetExitCodeProcess (proc->handle, &exitcode)) + must_kill = (exitcode == STILL_ACTIVE) ? GNUNET_YES : GNUNET_NO; + if (GNUNET_YES == must_kill) + if (0 == TerminateProcess (proc->handle, 0)) + { + SetErrnoFromWinError (GetLastError ()); + return -1; + } } return 0; #else -- 2.25.1