aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2017-08-03 12:35:40 +0100
committerRon Yorston <rmy@pobox.com>2017-08-03 12:35:40 +0100
commitee91cffef5d2dc60b62864f6a1ffb98eadd0a71a (patch)
tree57d65ad41cfe376febd86d87ef03a878af4c0dee /shell
parentc3ca46e619744ccd6c597417cc8e373149608909 (diff)
downloadbusybox-w32-ee91cffef5d2dc60b62864f6a1ffb98eadd0a71a.tar.gz
busybox-w32-ee91cffef5d2dc60b62864f6a1ffb98eadd0a71a.tar.bz2
busybox-w32-ee91cffef5d2dc60b62864f6a1ffb98eadd0a71a.zip
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.
Diffstat (limited to 'shell')
-rw-r--r--shell/ash.c5
1 files changed, 4 insertions, 1 deletions
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 */
4308static BOOL WINAPI ctrl_handler(DWORD dwCtrlType) 4308static BOOL WINAPI ctrl_handler(DWORD dwCtrlType)
4309{ 4309{
4310 if (dwCtrlType == CTRL_C_EVENT || dwCtrlType == CTRL_BREAK_EVENT) { 4310 if (dwCtrlType == CTRL_C_EVENT || dwCtrlType == CTRL_BREAK_EVENT) {
4311 SetEvent(hSIGINT);
4312 pending_int = 1; 4311 pending_int = 1;
4312 SetEvent(hSIGINT);
4313 return TRUE; 4313 return TRUE;
4314 } 4314 }
4315 return FALSE; 4315 return FALSE;
@@ -4379,6 +4379,8 @@ waitpid_child(int *status, int wait_flags)
4379 free(pidlist); 4379 free(pidlist);
4380 free(proclist); 4380 free(proclist);
4381 *status = 128 + SIGINT; /* terminated by a signal */ 4381 *status = 128 + SIGINT; /* terminated by a signal */
4382 if (iflag)
4383 write(STDOUT_FILENO, "^C", 2);
4382 return pid; 4384 return pid;
4383 } 4385 }
4384 GetExitCodeProcess(proclist[idx], &win_status); 4386 GetExitCodeProcess(proclist[idx], &win_status);
@@ -15126,6 +15128,7 @@ forkshell_init(const char *idstr)
15126 15128
15127 reinitvar(); 15129 reinitvar();
15128 15130
15131 shlvl++;
15129 forkshell_child(fs); 15132 forkshell_child(fs);
15130} 15133}
15131 15134