From 8db590e2431a18628a693d49e943d2c4d94cb85c Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Sat, 12 Oct 2024 09:46:24 +0100 Subject: kill: fix regression in 'kill -9' 'kill -9' was found to fail with an 'Invalid argument' error. This is a regression introduced by commit 569de936a (kill: killing a zombie process should fail). Use the correct argument to OpenProcess() for SIGKILL so it can query the exit code of the target process. Adds 16 bytes. (GitHub issue #465) --- win32/process.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/win32/process.c b/win32/process.c index 34ef3cffa..30739c96d 100644 --- a/win32/process.c +++ b/win32/process.c @@ -822,15 +822,16 @@ static int kill_signal(pid_t pid, int sig) { HANDLE process; int ret = 0; - DWORD code; + DWORD code, flags; if (sig == SIGKILL) - process = OpenProcess(PROCESS_TERMINATE, FALSE, pid); + flags = PROCESS_TERMINATE | PROCESS_QUERY_INFORMATION; else - process = OpenProcess(SYNCHRONIZE | PROCESS_CREATE_THREAD | - PROCESS_QUERY_INFORMATION | - PROCESS_VM_OPERATION | PROCESS_VM_WRITE | - PROCESS_VM_READ, FALSE, pid); + flags = SYNCHRONIZE | PROCESS_CREATE_THREAD | + PROCESS_QUERY_INFORMATION | + PROCESS_VM_OPERATION | PROCESS_VM_WRITE | + PROCESS_VM_READ; + process = OpenProcess(flags, FALSE, pid); if (!process) return -1; -- cgit v1.2.3-55-g6feb