From 96a647690a67141cf4edc76cd4f067617e0f69b6 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Fri, 18 Jun 2021 14:08:34 +0100 Subject: ash: prevent issue with ctrl-c and echo in loop Interrupting a loop like this: while true; do echo hello; done with ctrl-c caused the shell to exit. Turning off interrupts around the calls to echo_main() and printf_main() improves matters, though isn't a complete cure. --- shell/ash.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'shell') diff --git a/shell/ash.c b/shell/ash.c index 14712ef54..bab6138da 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -10815,12 +10815,35 @@ 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