Skip to content
Permalink
Browse files

fixup! mingw: kill child processes in a gentler way

Seems that this maintainer managed to merge a revision without the
last-minute changes.

This fix makes sure that the exit_status is preserved, and that it is
easier to reason about the main_process and why it is terminated and the
handle is closed only once (I am looking at you, Coverity!).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  • Loading branch information...
dscho committed May 23, 2017
1 parent 7cf4526 commit 3603d17801ddb54e444e1e01212a1b9f8e0ee251
Showing with 6 additions and 4 deletions.
  1. +6 −4 compat/win32/exit-process.h
@@ -63,16 +63,18 @@ static int terminate_process_tree(HANDLE main_process, int exit_status)
break;
}

for (i = len - 1; i >= 0; i--) {
HANDLE process = pids[i] == pid ? main_process :
OpenProcess(PROCESS_TERMINATE, FALSE, pids[i]);
for (i = len - 1; i > 0; i--) {
HANDLE process = OpenProcess(PROCESS_TERMINATE, FALSE, pids[i]);

if (process) {
if (!TerminateProcess(process, exit_status << 8))
if (!TerminateProcess(process, exit_status))
ret = -1;
CloseHandle(process);
}
}
if (!TerminateProcess(main_process, exit_status))
ret = -1;
CloseHandle(main_process);

return ret;
}

0 comments on commit 3603d17

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