Skip to content

Commit

Permalink
Call CloseHandle() after wait on Windows
Browse files Browse the repository at this point in the history
TerminateProcess() is "equivalent" to kill(), while
WaitForSingleObject() is "equivalent" to waitpid(), so the handle must
be closed after WaitForSingleObject().
  • Loading branch information
rom1v committed Jan 1, 2021
1 parent 83910d3 commit 05e8c1a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/src/sys/win/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -70,6 +70,7 @@ cmd_simple_wait(HANDLE handle, DWORD *exit_code) {
if (exit_code) {
*exit_code = code;
}
CloseHandle(handle);
return !code;
}

Expand Down

0 comments on commit 05e8c1a

Please sign in to comment.