From 2ed9b3d2e51ddcedcac75fbbe58f5c70d33c1bd8 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Mon, 10 Feb 2020 12:55:41 +0000 Subject: ash: fixes to trap If a trap is set for SIGINT don't call raise(SIGINT) in preadfd(), otherwise the shell exits because the signal isn't being caught. In forkshell_init() change the initialisation of trap and trap_ptr. --- shell/ash.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/shell/ash.c b/shell/ash.c index e032966bd..b3ec4caf8 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -11266,7 +11266,9 @@ preadfd(void) if (trap[SIGINT]) { buf[0] = '\n'; buf[1] = '\0'; +# if !ENABLE_PLATFORM_MINGW32 raise(SIGINT); +# endif return 1; } exitstatus = 128 + SIGINT; @@ -16216,9 +16218,8 @@ forkshell_init(const char *idstr) } } fs->gmp->exception_handler = ash_ptr_to_globals_misc->exception_handler; - for (i = 0; i < NSIG; i++) - fs->gmp->trap[i] = ash_ptr_to_globals_misc->trap[i]; - fs->gmp->trap_ptr = ash_ptr_to_globals_misc->trap_ptr; + memset(fs->gmp->trap, 0, sizeof(fs->gmp->trap[0])*NSIG); + fs->gmp->trap_ptr = fs->gmp->trap; /* Switch global variables */ gvpp = (struct globals_var **)&ash_ptr_to_globals_var; -- cgit v1.2.3-55-g6feb