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>
This commit is contained in:
parent
2eb0a7e1b9
commit
b4f51d32d2
11
shell/ash.c
11
shell/ash.c
@ -4660,19 +4660,19 @@ clear_traps(void)
|
|||||||
{
|
{
|
||||||
char **tp;
|
char **tp;
|
||||||
|
|
||||||
|
INT_OFF;
|
||||||
for (tp = trap; tp < &trap[NSIG]; tp++) {
|
for (tp = trap; tp < &trap[NSIG]; tp++) {
|
||||||
if (*tp && **tp) { /* trap not NULL or "" (SIG_IGN) */
|
if (*tp && **tp) { /* trap not NULL or "" (SIG_IGN) */
|
||||||
INT_OFF;
|
|
||||||
if (trap_ptr == trap)
|
if (trap_ptr == trap)
|
||||||
free(*tp);
|
free(*tp);
|
||||||
/* else: it "belongs" to trap_ptr vector, don't free */
|
/* else: it "belongs" to trap_ptr vector, don't free */
|
||||||
*tp = NULL;
|
*tp = NULL;
|
||||||
if ((tp - trap) != 0)
|
if ((tp - trap) != 0)
|
||||||
setsignal(tp - trap);
|
setsignal(tp - trap);
|
||||||
INT_ON;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
may_have_traps = 0;
|
may_have_traps = 0;
|
||||||
|
INT_ON;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Lives far away from here, needed for forkchild */
|
/* Lives far away from here, needed for forkchild */
|
||||||
@ -12753,12 +12753,13 @@ trapcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
|||||||
if (action) {
|
if (action) {
|
||||||
if (LONE_DASH(action))
|
if (LONE_DASH(action))
|
||||||
action = NULL;
|
action = NULL;
|
||||||
else
|
else {
|
||||||
|
if (action[0]) /* not NULL and not "" and not "-" */
|
||||||
|
may_have_traps = 1;
|
||||||
action = ckstrdup(action);
|
action = ckstrdup(action);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
free(trap[signo]);
|
free(trap[signo]);
|
||||||
if (action)
|
|
||||||
may_have_traps = 1;
|
|
||||||
trap[signo] = action;
|
trap[signo] = action;
|
||||||
if (signo != 0)
|
if (signo != 0)
|
||||||
setsignal(signo);
|
setsignal(signo);
|
||||||
|
Loading…
Reference in New Issue
Block a user