From 50ee6f12db1596d610f7c56a635d3d985352f6c9 Mon Sep 17 00:00:00 2001 From: LRN Date: Fri, 13 Jul 2012 16:24:41 +0000 Subject: [PATCH] W32: correct handling of crazy W32 process quirks --- src/util/os_priority.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/util/os_priority.c b/src/util/os_priority.c index b0668e20d..b20c3272d 100644 --- a/src/util/os_priority.c +++ b/src/util/os_priority.c @@ -464,12 +464,27 @@ GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc, int sig) if (0 == SafeTerminateProcess (proc->handle, 0, 0)) { DWORD error_code = GetLastError (); - if (error_code != WAIT_TIMEOUT) /* OK, since timeout is 0 */ + if ((error_code != WAIT_TIMEOUT) && (error_code != ERROR_PROCESS_ABORTED)) { - LOG (GNUNET_ERROR_TYPE_WARNING, + LOG ((error_code == ERROR_ACCESS_DENIED) ? + GNUNET_ERROR_TYPE_INFO : GNUNET_ERROR_TYPE_WARNING, "SafeTermiateProcess failed with code %lu\n", error_code); - SetErrnoFromWinError (error_code); - return -1; + /* The problem here is that a process that is already dying + * might cause SafeTerminateProcess to fail with + * ERROR_ACCESS_DENIED, but the process WILL die eventually. + * If we really had a permissions problem, hanging up (which + * is what will happen in process_wait() in that case) is + * a valid option. + */ + if (error_code == ERROR_ACCESS_DENIED) + { + errno = 0; + } + else + { + SetErrnoFromWinError (error_code); + return -1; + } } } } -- 2.25.1