7
Bug-Reported-by: Andreas Schwab <schwab@suse.de>
8
Bug-Reference-ID: <mvmv8opcbha.fsf@suse.de>
9
Bug-Reference-URL: https://lists.gnu.org/archive/html/bug-bash/2022-10/msg00076.html
13
Bash defers processing additional terminating signals when running the
14
EXIT trap while exiting due to a terminating signal. This patch allows the
15
new terminating signal to kill the shell immediately.
17
Patch (apply with `patch -p0'):
19
*** ../bash-5.2-patched/execute_cmd.c 2022-11-23 17:09:18.000000000 -0500
20
--- execute_cmd.c 2022-11-28 10:36:08.000000000 -0500
29
*** ../bash-5.2-patched/sig.c 2021-11-04 14:15:31.000000000 -0400
30
--- sig.c 2022-12-06 09:45:11.000000000 -0500
35
static void initialize_shell_signals PARAMS((void));
36
+ static void kill_shell PARAMS((int));
44
+ static int handling_termsig = 0;
47
termsig_sighandler (sig)
51
terminate_immediately = 1;
53
+ /* If we are currently handling a terminating signal, we have a couple of
54
+ choices here. We can ignore this second terminating signal and let the
55
+ shell exit from the first one, or we can exit immediately by killing
56
+ the shell with this signal. This code implements the latter; to implement
57
+ the former, replace the kill_shell(sig) with return. */
58
+ if (handling_termsig)
59
+ kill_shell (sig); /* just short-circuit now */
61
terminating_signal = sig;
67
- static int handling_termsig = 0;
71
/* Simple semaphore to keep this function from being executed multiple
72
times. Since we no longer are running as a signal handler, we don't
78
! handling_termsig = 1;
79
terminating_signal = 0; /* keep macro from re-testing true. */
85
! handling_termsig = terminating_signal; /* for termsig_sighandler */
86
terminating_signal = 0; /* keep macro from re-testing true. */
91
run_exit_trap (); /* XXX - run exit trap possibly in signal context? */
103
/* We don't change the set of blocked signals. If a user starts the shell
104
with a terminating signal blocked, we won't get here (and if by some
105
*** ../bash-5.2/patchlevel.h 2020-06-22 14:51:03.000000000 -0400
106
--- patchlevel.h 2020-10-01 11:01:28.000000000 -0400
109
looks for to find the patch level (for the sccs version string). */
111
! #define PATCHLEVEL 13
113
#endif /* _PATCHLEVEL_H_ */
115
looks for to find the patch level (for the sccs version string). */
117
! #define PATCHLEVEL 14
119
#endif /* _PATCHLEVEL_H_ */