From: Christian Grothoff Date: Sat, 23 Jun 2012 22:29:39 +0000 (+0000) Subject: -LRN: Better process termination for W32: X-Git-Tag: initial-import-from-subversion-38251~12856 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=bc0c61a40a5c68c1fbefc475735e88788e6b1bc4;p=oweals%2Fgnunet.git -LRN: Better process termination for W32: Avoids spewing warnings about killing processes that are already dead. Also removes a FIXME. --- 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