From b8d57003cf8d175f7b854240d2bf01fcce8f3ffd Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Tue, 27 Mar 2018 14:35:53 +0100 Subject: ash: use SIGTERM to kill processes When Ctrl-C is pressed try killing processes with SIGTERM initially. If they're still running after a short pause use sterner measures. --- shell/ash.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/shell/ash.c b/shell/ash.c index c7c514417..586925835 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -4472,7 +4472,15 @@ waitpid_child(int *status, int wait_flags) int i; ResetEvent(hSIGINT); for (i = 1; i < pid_nr; i++) - TerminateProcess(proclist[i], 1); + kill_SIGTERM_by_handle(proclist[i], 128+SIGINT); + Sleep(200); + for (i = 1; i < pid_nr; i++) { + DWORD code; + if (GetExitCodeProcess(proclist[i], &code) && + code == STILL_ACTIVE) { + TerminateProcess(proclist[i], 128+SIGINT); + } + } pid = pidlist[1]; free(pidlist); free(proclist); -- cgit v1.2.3-55-g6feb