summaryrefslogtreecommitdiff
path: root/shell/ash.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2020-02-08 16:48:40 +0000
committerRon Yorston <rmy@pobox.com>2020-02-08 16:48:40 +0000
commit8152e92d3abfff0386a672421e164ce163678dcf (patch)
tree2246535e3516556c7486c5b589d7fe82d6691e55 /shell/ash.c
parent47dbad5047e6bb9fb1f287245791711ceb822c96 (diff)
downloadbusybox-w32-8152e92d3abfff0386a672421e164ce163678dcf.tar.gz
busybox-w32-8152e92d3abfff0386a672421e164ce163678dcf.tar.bz2
busybox-w32-8152e92d3abfff0386a672421e164ce163678dcf.zip
ash: fixes to handling of ctrl-C in read builtin
Consider this script: while read -r; do echo $REPLY; done echo hello There are currently two problems with this when the read is interrupted by ctrl-C: - The error return code is 0 when it should be 130; - The echo command is executed. Fix these issues by propagating the control event to the process that would have caught it if the read builtin hadn't grabbed keyboard input.
Diffstat (limited to 'shell/ash.c')
-rw-r--r--shell/ash.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 2a7941702..f23d63b21 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -14701,6 +14701,21 @@ readcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
14701 goto again; 14701 goto again;
14702 } 14702 }
14703 14703
14704#if ENABLE_PLATFORM_MINGW32
14705 if ((uintptr_t)r == 2) {
14706 /* ^C pressed, propagate event */
14707 if (iflag) {
14708 write(STDOUT_FILENO, "^C", 2);
14709 raise_interrupt();
14710 }
14711 else {
14712 GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0);
14713 exitshell();
14714 }
14715 return (uintptr_t)r;
14716 }
14717#endif
14718
14704 if ((uintptr_t)r > 1) 14719 if ((uintptr_t)r > 1)
14705 ash_msg_and_raise_error(r); 14720 ash_msg_and_raise_error(r);
14706 14721