summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorDenys Vlasenko2009-09-24 03:09:26 +0200
committerDenys Vlasenko2009-09-24 03:09:26 +0200
commit0800e3af75461c6322427dab53d3526066453b04 (patch)
tree35e36872f94901b85b6635d515302e0199800e64 /shell
parent718854025735db26a0dda9e6acfe785d2004b3bc (diff)
downloadbusybox-0800e3af75461c6322427dab53d3526066453b04.zip
busybox-0800e3af75461c6322427dab53d3526066453b04.tar.gz
ash: do not let EXIT trap to fire in `trap`
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r--shell/ash.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 597bc28..47f968b 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -4525,7 +4525,7 @@ clear_traps(void)
INT_OFF;
free(*tp);
*tp = NULL;
- if (tp != &trap[0])
+ if ((tp - trap) != 0)
setsignal(tp - trap);
INT_ON;
}
@@ -4596,6 +4596,8 @@ forkchild(struct job *jp, union node *n, int mode)
*
* Our solution: ONLY bare $(trap) or `trap` is special.
*/
+ free(trap[0]); /* Prevent EXIT trap from firing in `trap` */
+ trap[0] = NULL;
} else {
clear_traps();
}
@@ -13023,6 +13025,7 @@ exitshell(void)
if (p) {
trap[0] = NULL;
evalstring(p, 0);
+ free(p);
}
flush_stdout_stderr();
out: