From 7e4525f4a356d27c99d9d556922c1634c9c29cd6 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Tue, 4 Aug 2026 11:50:00 +0200 Subject: [PATCH] Close process handle in os_kill on Windows --- os/mingw.c | 3 +++ os/os.h | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/os/mingw.c b/os/mingw.c index 49a55744..4da952a9 100644 --- a/os/mingw.c +++ b/os/mingw.c @@ -2848,9 +2848,12 @@ int os_kill(pid_t pid) if (!TerminateProcess(h, 1)) { windows_errno(GetLastError()); + CloseHandle(h); return -1; } + CloseHandle(h); + return 0; } diff --git a/os/os.h b/os/os.h index 8180b3e0..042d5fe0 100644 --- a/os/os.h +++ b/os/os.h @@ -135,13 +135,14 @@ pid_t os_wait(pid_t pid, int* status); /** * Terminate gracefully a process. + * The caller must subsequently call os_wait() to reap process resources and close handles. * \param pid Process ID of the process to terminate. * \return 0 on success, -1 on failure. */ int os_term(pid_t pid); /** - * Forcibly terminate a process. + * Forcibly terminate a process and release its handle/process resources. * \param pid Process ID of the process to kill. * \return 0 on success, -1 on failure. */