From 05e8c1a3c5e955d2941d882e5fe784e6695e3ec4 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Fri, 1 Jan 2021 23:39:29 +0100 Subject: [PATCH] Call CloseHandle() after wait on Windows TerminateProcess() is "equivalent" to kill(), while WaitForSingleObject() is "equivalent" to waitpid(), so the handle must be closed after WaitForSingleObject(). --- app/src/sys/win/command.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/sys/win/command.c b/app/src/sys/win/command.c index fbc0d04cb2..7b48330060 100644 --- a/app/src/sys/win/command.c +++ b/app/src/sys/win/command.c @@ -56,7 +56,7 @@ cmd_execute(const char *const argv[], HANDLE *handle) { bool cmd_terminate(HANDLE handle) { - return TerminateProcess(handle, 1) && CloseHandle(handle); + return TerminateProcess(handle, 1); } bool @@ -70,6 +70,7 @@ cmd_simple_wait(HANDLE handle, DWORD *exit_code) { if (exit_code) { *exit_code = code; } + CloseHandle(handle); return !code; }