diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-09-25 02:12:27 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-09-25 02:12:27 +0200 |
commit | e305c28285ac365d6573802b33a2d542fd236022 (patch) | |
tree | e5aad8a39d4c09fedaa99a98293a7303f22cd91b /shell | |
parent | c297ea97e288da16216d5c121ddefa7b61923847 (diff) | |
download | busybox-e305c28285ac365d6573802b33a2d542fd236022.tar.gz |
ash: slightly better (more correct) code for "trap hack"
function old new delta
changepath 194 195 +1
evalvar 1373 1371 -2
forkchild 602 590 -12
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ash.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/shell/ash.c b/shell/ash.c index b30dc7728..37bdc701a 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -4526,7 +4526,9 @@ clear_traps(void) for (tp = trap; tp < &trap[NSIG]; tp++) { if (*tp && **tp) { /* trap not NULL or "" (SIG_IGN) */ INT_OFF; - free(*tp); + if (trap_ptr == trap) + free(*tp); + /* else: it "belongs" to trap_ptr vector, don't free */ *tp = NULL; if ((tp - trap) != 0) setsignal(tp - trap); @@ -4602,10 +4604,8 @@ forkchild(struct job *jp, union node *n, int mode) /* This is needed to prevent EXIT trap firing and such * (trap_ptr will be freed in trapcmd()) */ trap_ptr = memcpy(xmalloc(sizeof(trap)), trap, sizeof(trap)); - memset(trap, 0, sizeof(trap)); - } else { - clear_traps(); } + clear_traps(); #if JOBS /* do job control only in root shell */ doing_jobctl = 0; |