Skip to content
Permalink
Browse files

fixup! mingw: kill child processes in a gentler way

Let's make sure that CloseHandle() is called on the process only once.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  • Loading branch information...
dscho committed May 24, 2017
1 parent 3603d17 commit fe31e2c27c1b42c2ccf15f0987f4d7a90c5557c5
Showing with 6 additions and 3 deletions.
  1. +3 −2 compat/mingw.c
  2. +3 −1 compat/win32/exit-process.h
@@ -1814,9 +1814,10 @@ int mingw_kill(pid_t pid, int sig)
}
ret = terminate_process_tree(h, 128 + sig);
}
CloseHandle(h);
if (ret)
if (ret) {
errno = err_win_to_posix(GetLastError());
CloseHandle(h);
}
return ret;
} else if (pid > 0 && sig == 0) {
HANDLE h = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);
@@ -149,8 +149,10 @@ static int exit_process(HANDLE process, int exit_code)
* killing the process tree via TerminateProcess().
*/
if (WaitForSingleObject(process, 10000) ==
WAIT_OBJECT_0)
WAIT_OBJECT_0) {
CloseHandle(process);
return 0;
}
}

return terminate_process_tree(process, exit_code);

0 comments on commit fe31e2c

Please sign in to comment.
You can’t perform that action at this time.