aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2016-10-27 12:55:09 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2016-10-27 12:55:09 +0200
commitb4f51d32d288a985019884d79515b1d7a8251529 (patch)
treee39a0f9e90805e62998d8aedef3165eea5f950a1
parent2eb0a7e1b9a579ba34e4780c9ed8e74f38bc6b85 (diff)
downloadbusybox-w32-b4f51d32d288a985019884d79515b1d7a8251529.tar.gz
busybox-w32-b4f51d32d288a985019884d79515b1d7a8251529.tar.bz2
busybox-w32-b4f51d32d288a985019884d79515b1d7a8251529.zip
ash: partially sync with dash on "fork if traps are set" logic
Upstream commit "[EVAL] Force fork if any trap is set, not just on EXIT" had a similar code as our fix to that bug. Eliminate some superficial differences. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--shell/ash.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 0dd440c61..c575e1036 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -4660,19 +4660,19 @@ clear_traps(void)
4660{ 4660{
4661 char **tp; 4661 char **tp;
4662 4662
4663 INT_OFF;
4663 for (tp = trap; tp < &trap[NSIG]; tp++) { 4664 for (tp = trap; tp < &trap[NSIG]; tp++) {
4664 if (*tp && **tp) { /* trap not NULL or "" (SIG_IGN) */ 4665 if (*tp && **tp) { /* trap not NULL or "" (SIG_IGN) */
4665 INT_OFF;
4666 if (trap_ptr == trap) 4666 if (trap_ptr == trap)
4667 free(*tp); 4667 free(*tp);
4668 /* else: it "belongs" to trap_ptr vector, don't free */ 4668 /* else: it "belongs" to trap_ptr vector, don't free */
4669 *tp = NULL; 4669 *tp = NULL;
4670 if ((tp - trap) != 0) 4670 if ((tp - trap) != 0)
4671 setsignal(tp - trap); 4671 setsignal(tp - trap);
4672 INT_ON;
4673 } 4672 }
4674 } 4673 }
4675 may_have_traps = 0; 4674 may_have_traps = 0;
4675 INT_ON;
4676} 4676}
4677 4677
4678/* Lives far away from here, needed for forkchild */ 4678/* Lives far away from here, needed for forkchild */
@@ -12753,12 +12753,13 @@ trapcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
12753 if (action) { 12753 if (action) {
12754 if (LONE_DASH(action)) 12754 if (LONE_DASH(action))
12755 action = NULL; 12755 action = NULL;
12756 else 12756 else {
12757 if (action[0]) /* not NULL and not "" and not "-" */
12758 may_have_traps = 1;
12757 action = ckstrdup(action); 12759 action = ckstrdup(action);
12760 }
12758 } 12761 }
12759 free(trap[signo]); 12762 free(trap[signo]);
12760 if (action)
12761 may_have_traps = 1;
12762 trap[signo] = action; 12763 trap[signo] = action;
12763 if (signo != 0) 12764 if (signo != 0)
12764 setsignal(signo); 12765 setsignal(signo);