Skip to content

Commit 664e634

Browse files
committed
squash! kill: Handle Win32 console processes' children, too
kill: kill Win32 processes more gently This change is the equivalent to the change to the Ctrl+C handling we just made. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent d9c290c commit 664e634

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

winsup/utils/kill.cc

+6-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ details. */
1717
#include <cygwin/version.h>
1818
#include <getopt.h>
1919
#include <limits.h>
20+
#include <cygwin/exit_process.h>
2021

2122
static char *prog_name;
2223

@@ -162,7 +163,10 @@ forcekill (int pid, int sig, int wait)
162163
if (pid > 0)
163164
p = (external_pinfo *) cygwin_internal (CW_GETPINFO_FULL, pid);
164165
DWORD dwpid = p ? p->dwProcessId : (DWORD) pid;
165-
HANDLE h = OpenProcess (PROCESS_TERMINATE, FALSE, (DWORD) dwpid);
166+
HANDLE h = OpenProcess (PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION |
167+
PROCESS_VM_OPERATION | PROCESS_VM_WRITE |
168+
PROCESS_VM_READ | PROCESS_TERMINATE,
169+
FALSE, (DWORD) dwpid);
166170
if (!h)
167171
{
168172
if (!wait || GetLastError () != ERROR_INVALID_PARAMETER)
@@ -173,7 +177,7 @@ forcekill (int pid, int sig, int wait)
173177
if (!wait || WaitForSingleObject (h, 200) != WAIT_OBJECT_0)
174178
{
175179
if (sig == SIGINT || sig == SIGTERM)
176-
kill_process_tree (dwpid, sig);
180+
exit_process (h, 128 + sig);
177181
else if (sig && !TerminateProcess (h, sig << 8)
178182
&& WaitForSingleObject (h, 200) != WAIT_OBJECT_0)
179183
fprintf (stderr, "%s: couldn't kill pid %u, %u\n",

0 commit comments

Comments
 (0)