]>
Commit | Line | Data |
---|---|---|
7ea6cba0 AB |
1 | BASH PATCH REPORT |
2 | ================= | |
3 | ||
4 | Bash-Release: 5.2 | |
5 | Patch-ID: bash52-014 | |
6 | ||
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 | |
10 | ||
11 | Bug-Description: | |
12 | ||
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. | |
16 | ||
17 | Patch (apply with `patch -p0'): | |
18 | ||
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 | |
21 | *************** | |
22 | *** 3625,3628 **** | |
23 | --- 3649,3653 ---- | |
24 | ||
25 | dispose_words (es); | |
26 | + QUIT; | |
27 | ||
28 | if (match) | |
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 | |
31 | *************** | |
32 | *** 95,98 **** | |
33 | --- 95,99 ---- | |
34 | ||
35 | static void initialize_shell_signals PARAMS((void)); | |
36 | + static void kill_shell PARAMS((int)); | |
37 | ||
38 | void | |
39 | *************** | |
40 | *** 487,490 **** | |
41 | --- 495,500 ---- | |
42 | } | |
43 | ||
44 | + static int handling_termsig = 0; | |
45 | + | |
46 | sighandler | |
47 | termsig_sighandler (sig) | |
48 | *************** | |
49 | *** 533,536 **** | |
50 | --- 543,554 ---- | |
51 | terminate_immediately = 1; | |
52 | ||
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 */ | |
60 | + | |
61 | terminating_signal = sig; | |
62 | ||
63 | *************** | |
64 | *** 565,572 **** | |
65 | int sig; | |
66 | { | |
67 | - static int handling_termsig = 0; | |
68 | - int i, core; | |
69 | - sigset_t mask; | |
70 | - | |
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 | |
73 | --- 585,588 ---- | |
74 | *************** | |
75 | *** 574,578 **** | |
76 | if (handling_termsig) | |
77 | return; | |
78 | ! handling_termsig = 1; | |
79 | terminating_signal = 0; /* keep macro from re-testing true. */ | |
80 | ||
81 | --- 590,595 ---- | |
82 | if (handling_termsig) | |
83 | return; | |
84 | ! | |
85 | ! handling_termsig = terminating_signal; /* for termsig_sighandler */ | |
86 | terminating_signal = 0; /* keep macro from re-testing true. */ | |
87 | ||
88 | *************** | |
89 | *** 614,617 **** | |
90 | --- 631,644 ---- | |
91 | run_exit_trap (); /* XXX - run exit trap possibly in signal context? */ | |
92 | ||
93 | + kill_shell (sig); | |
94 | + } | |
95 | + | |
96 | + static void | |
97 | + kill_shell (sig) | |
98 | + int sig; | |
99 | + { | |
100 | + int i, core; | |
101 | + sigset_t mask; | |
102 | + | |
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 | |
107 | *************** | |
108 | *** 26,30 **** | |
109 | looks for to find the patch level (for the sccs version string). */ | |
110 | ||
111 | ! #define PATCHLEVEL 13 | |
112 | ||
113 | #endif /* _PATCHLEVEL_H_ */ | |
114 | --- 26,30 ---- | |
115 | looks for to find the patch level (for the sccs version string). */ | |
116 | ||
117 | ! #define PATCHLEVEL 14 | |
118 | ||
119 | #endif /* _PATCHLEVEL_H_ */ |