summaryrefslogtreecommitdiff
authorDenys Vlasenko <vda.linux@googlemail.com>2016-11-08 03:59:11 (GMT)
committer Denys Vlasenko <vda.linux@googlemail.com>2016-11-08 03:59:11 (GMT)
commit830ea35484cecb8b4cdbe0f30cc5d573ff0e3411 (patch)
tree9057122598e964984f9bda62a75d7cb746cd602f
parent02affb4afd4a71b0c1ca6286f9b0f6bf3b10e0a1 (diff)
downloadbusybox-830ea35484cecb8b4cdbe0f30cc5d573ff0e3411.zip
busybox-830ea35484cecb8b4cdbe0f30cc5d573ff0e3411.tar.gz
busybox-830ea35484cecb8b4cdbe0f30cc5d573ff0e3411.tar.bz2
hush: make "wait %1" less likely to play with signal mask
Was playing with "sleep 3 | exit 3 & wait %1" and noticed that often SIGCHLD arrives even before I get to signal masking. Can avoid it in this case. function old new delta wait_for_child_or_signal 228 265 +37 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat
-rw-r--r--shell/hush.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/shell/hush.c b/shell/hush.c
index ddbf2f7..5e51adf 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -8146,11 +8146,11 @@ static void install_fatal_sighandlers(void)
/* We will restore tty pgrp on these signals */
mask = 0
- + (1 << SIGILL ) * HUSH_DEBUG
- + (1 << SIGFPE ) * HUSH_DEBUG
+ /*+ (1 << SIGILL ) * HUSH_DEBUG*/
+ /*+ (1 << SIGFPE ) * HUSH_DEBUG*/
+ (1 << SIGBUS ) * HUSH_DEBUG
+ (1 << SIGSEGV) * HUSH_DEBUG
- + (1 << SIGTRAP) * HUSH_DEBUG
+ /*+ (1 << SIGTRAP) * HUSH_DEBUG*/
+ (1 << SIGABRT)
/* bash 3.2 seems to handle these just like 'fatal' ones */
+ (1 << SIGPIPE)
@@ -9518,6 +9518,9 @@ static int wait_for_child_or_signal(struct pipe *waitfor_pipe, pid_t waitfor_pid
int sig;
sigset_t oldset;
+ if (!sigisemptyset(&G.pending_set))
+ goto check_sig;
+
/* waitpid is not interruptible by SA_RESTARTed
* signals which we use. Thus, this ugly dance:
*/
@@ -9532,7 +9535,6 @@ static int wait_for_child_or_signal(struct pipe *waitfor_pipe, pid_t waitfor_pid
if (!sigisemptyset(&G.pending_set)) {
/* Crap! we raced with some signal! */
- // sig = 0;
goto restore;
}
@@ -9567,13 +9569,10 @@ static int wait_for_child_or_signal(struct pipe *waitfor_pipe, pid_t waitfor_pid
sigsuspend(&oldset);
restore:
sigprocmask(SIG_SETMASK, &oldset, NULL);
-
+ check_sig:
/* So, did we get a signal? */
- //if (sig > 0)
- // raise(sig); /* run handler */
sig = check_and_run_traps();
if (sig /*&& sig != SIGCHLD - always true */) {
- /* see note 2 */
ret = 128 + sig;
break;
}