aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-08-06 20:06:19 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-08-06 20:06:19 +0200
commit0f14f41e72d48836a5287d00f05cea236b25be40 (patch)
tree35032020e6b9518097ab9c9bab90369fe63df1a4
parented7d118dd0cfda7be21dafae5eb34b0d419f62ec (diff)
downloadbusybox-w32-0f14f41e72d48836a5287d00f05cea236b25be40.tar.gz
busybox-w32-0f14f41e72d48836a5287d00f05cea236b25be40.tar.bz2
busybox-w32-0f14f41e72d48836a5287d00f05cea236b25be40.zip
ash: do not set a signal to SIG_DFL if it already is
function old new delta setsignal 312 338 +26 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--shell/ash.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/shell/ash.c b/shell/ash.c
index e80425f5e..e8f3ed26b 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -366,7 +366,7 @@ struct globals_misc {
366#define S_DFL 1 /* default signal handling (SIG_DFL) */ 366#define S_DFL 1 /* default signal handling (SIG_DFL) */
367#define S_CATCH 2 /* signal is caught */ 367#define S_CATCH 2 /* signal is caught */
368#define S_IGN 3 /* signal is ignored (SIG_IGN) */ 368#define S_IGN 3 /* signal is ignored (SIG_IGN) */
369#define S_HARD_IGN 4 /* signal is ignored permanently */ 369#define S_HARD_IGN 4 /* signal is ignored permanently (it was SIG_IGN on entry to shell) */
370 370
371 /* indicates specified signal received */ 371 /* indicates specified signal received */
372 uint8_t gotsig[NSIG - 1]; /* offset by 1: "signal" 0 is meaningless */ 372 uint8_t gotsig[NSIG - 1]; /* offset by 1: "signal" 0 is meaningless */
@@ -3566,6 +3566,12 @@ setsignal(int signo)
3566 cur_act = S_IGN; /* don't hard ignore these */ 3566 cur_act = S_IGN; /* don't hard ignore these */
3567 } 3567 }
3568 } 3568 }
3569 if (act.sa_handler == SIG_DFL && new_act == S_DFL) {
3570 /* installing SIG_DFL over SIG_DFL is a no-op */
3571 /* saves one sigaction call in each "sh -c SCRIPT" invocation */
3572 *t = S_DFL;
3573 return;
3574 }
3569 } 3575 }
3570 if (cur_act == S_HARD_IGN || cur_act == new_act) 3576 if (cur_act == S_HARD_IGN || cur_act == new_act)
3571 return; 3577 return;