Skip to content

Commit fe31e2c

Browse files
committed
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 <[email protected]>
1 parent 3603d17 commit fe31e2c

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

compat/mingw.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1814,9 +1814,10 @@ int mingw_kill(pid_t pid, int sig)
18141814
}
18151815
ret = terminate_process_tree(h, 128 + sig);
18161816
}
1817-
CloseHandle(h);
1818-
if (ret)
1817+
if (ret) {
18191818
errno = err_win_to_posix(GetLastError());
1819+
CloseHandle(h);
1820+
}
18201821
return ret;
18211822
} else if (pid > 0 && sig == 0) {
18221823
HANDLE h = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);

compat/win32/exit-process.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,10 @@ static int exit_process(HANDLE process, int exit_code)
149149
* killing the process tree via TerminateProcess().
150150
*/
151151
if (WaitForSingleObject(process, 10000) ==
152-
WAIT_OBJECT_0)
152+
WAIT_OBJECT_0) {
153+
CloseHandle(process);
153154
return 0;
155+
}
154156
}
155157

156158
return terminate_process_tree(process, exit_code);

0 commit comments

Comments
 (0)