From 96c104a61c9a75c478eb6e830653a830d72fe8fb Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Sun, 27 Feb 2022 12:56:21 +0000 Subject: ash: try harder to avoid ctrl-c issue Commit 96a647690 (ash: prevent issue with ctrl-c and echo in loop) attempted to fix the problem that interrupting a loop like: while true; do echo hello; done caused the shell to exit. However, it wasn't completely effective and it only applied to echo and printf, not other builtins. Revert 96a647690 and instead don't call raise_interrupt() from crtl_handler() for the foreground interactive shell. --- shell/ash.c | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/shell/ash.c b/shell/ash.c index c9122b291..d8f9dba34 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -4788,7 +4788,7 @@ sprint_status48(char *os, int status, int sigonly) static BOOL WINAPI ctrl_handler(DWORD dwCtrlType) { if (dwCtrlType == CTRL_C_EVENT || dwCtrlType == CTRL_BREAK_EVENT) { - if (!suppress_int) + if (!suppress_int && !(rootshell && iflag)) raise_interrupt(); /* does not return */ pending_int = 1; return TRUE; @@ -10970,35 +10970,12 @@ static int ulimitcmd(int, char **) FAST_FUNC; #define BUILTIN_SPEC_REG_ASSG "7" /* Stubs for calling non-FAST_FUNC's */ -#if !ENABLE_PLATFORM_MINGW32 #if ENABLE_ASH_ECHO static int FAST_FUNC echocmd(int argc, char **argv) { return echo_main(argc, argv); } #endif #if ENABLE_ASH_PRINTF static int FAST_FUNC printfcmd(int argc, char **argv) { return printf_main(argc, argv); } #endif -#else -#if ENABLE_ASH_ECHO -static int FAST_FUNC echocmd(int argc, char **argv) -{ - int ret; - INT_OFF; - ret = echo_main(argc, argv); - INT_ON; - return ret; -} -#endif -#if ENABLE_ASH_PRINTF -static int FAST_FUNC printfcmd(int argc, char **argv) -{ - int ret; - INT_OFF; - ret = printf_main(argc, argv); - INT_ON; - return ret; -} -#endif -#endif #if ENABLE_ASH_TEST || BASH_TEST2 static int FAST_FUNC testcmd(int argc, char **argv) { return test_main(argc, argv); } #endif -- cgit v1.2.3-55-g6feb