aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-09-25 02:12:27 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-09-25 02:12:27 +0200
commite305c28285ac365d6573802b33a2d542fd236022 (patch)
treee5aad8a39d4c09fedaa99a98293a7303f22cd91b
parentc297ea97e288da16216d5c121ddefa7b61923847 (diff)
downloadbusybox-w32-e305c28285ac365d6573802b33a2d542fd236022.tar.gz
busybox-w32-e305c28285ac365d6573802b33a2d542fd236022.tar.bz2
busybox-w32-e305c28285ac365d6573802b33a2d542fd236022.zip
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>
-rw-r--r--shell/ash.c8
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)
4526 for (tp = trap; tp < &trap[NSIG]; tp++) { 4526 for (tp = trap; tp < &trap[NSIG]; tp++) {
4527 if (*tp && **tp) { /* trap not NULL or "" (SIG_IGN) */ 4527 if (*tp && **tp) { /* trap not NULL or "" (SIG_IGN) */
4528 INT_OFF; 4528 INT_OFF;
4529 free(*tp); 4529 if (trap_ptr == trap)
4530 free(*tp);
4531 /* else: it "belongs" to trap_ptr vector, don't free */
4530 *tp = NULL; 4532 *tp = NULL;
4531 if ((tp - trap) != 0) 4533 if ((tp - trap) != 0)
4532 setsignal(tp - trap); 4534 setsignal(tp - trap);
@@ -4602,10 +4604,8 @@ forkchild(struct job *jp, union node *n, int mode)
4602 /* This is needed to prevent EXIT trap firing and such 4604 /* This is needed to prevent EXIT trap firing and such
4603 * (trap_ptr will be freed in trapcmd()) */ 4605 * (trap_ptr will be freed in trapcmd()) */
4604 trap_ptr = memcpy(xmalloc(sizeof(trap)), trap, sizeof(trap)); 4606 trap_ptr = memcpy(xmalloc(sizeof(trap)), trap, sizeof(trap));
4605 memset(trap, 0, sizeof(trap));
4606 } else {
4607 clear_traps();
4608 } 4607 }
4608 clear_traps();
4609#if JOBS 4609#if JOBS
4610 /* do job control only in root shell */ 4610 /* do job control only in root shell */
4611 doing_jobctl = 0; 4611 doing_jobctl = 0;