From ee91cffef5d2dc60b62864f6a1ffb98eadd0a71a Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Thu, 3 Aug 2017 12:35:40 +0100 Subject: ash: improvements to ctrl-c handling Setting pending_int *before* hSIGINT improves the behaviour when interrupting a shell script. Echo '^C' to the console when handling an interrupt. Increment shlvl in forkshell_init. On non-WIN32 platforms this was done in forkchild. --- shell/ash.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'shell') diff --git a/shell/ash.c b/shell/ash.c index 758187ccd..6a572cbc3 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -4308,8 +4308,8 @@ HANDLE hSIGINT; /* Ctrl-C is pressed */ static BOOL WINAPI ctrl_handler(DWORD dwCtrlType) { if (dwCtrlType == CTRL_C_EVENT || dwCtrlType == CTRL_BREAK_EVENT) { - SetEvent(hSIGINT); pending_int = 1; + SetEvent(hSIGINT); return TRUE; } return FALSE; @@ -4379,6 +4379,8 @@ waitpid_child(int *status, int wait_flags) free(pidlist); free(proclist); *status = 128 + SIGINT; /* terminated by a signal */ + if (iflag) + write(STDOUT_FILENO, "^C", 2); return pid; } GetExitCodeProcess(proclist[idx], &win_status); @@ -15126,6 +15128,7 @@ forkshell_init(const char *idstr) reinitvar(); + shlvl++; forkshell_child(fs); } -- cgit v1.2.3-55-g6feb