diff options
author | Chet Ramey <chet.ramey@case.edu> | 2011-12-29 13:05:52 -0500 |
---|---|---|
committer | Chet Ramey <chet.ramey@case.edu> | 2011-12-29 13:05:52 -0500 |
commit | c1854f2dd6a5ab4c240bf697f86856511b2d1660 (patch) | |
tree | d4ebaaebff5079f481f9f5d197d56a5b660bc18f /trap.c | |
parent | 7df0c1b2df350299db28d8742c4b3ce57a907314 (diff) | |
download | bash-c1854f2dd6a5ab4c240bf697f86856511b2d1660.tar.gz |
commit bash-20110325 snapshot
Diffstat (limited to 'trap.c')
-rw-r--r-- | trap.c | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -1,7 +1,7 @@ /* trap.c -- Not the trap command, but useful functions for manipulating those objects. The trap command is in builtins/trap.def. */ -/* Copyright (C) 1987-2010 Free Software Foundation, Inc. +/* Copyright (C) 1987-2011 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -176,7 +176,7 @@ initialize_traps () } } -#ifdef INCLUDE_UNUSED +#ifdef DEBUG /* Return a printable representation of the trap handler for SIG. */ static char * trap_handler_string (sig) @@ -276,6 +276,8 @@ run_pending_traps () if (catch_flag == 0) /* simple optimization */ return; +itrace("run_pending_traps: "); + catch_flag = 0; /* Preserve $? when running trap. */ @@ -387,6 +389,8 @@ trap_handler (sig) SIGRETURN (0); } +itrace("trap_handler: sig = %d", sig); + if ((sig >= NSIG) || (trap_list[sig] == (char *)DEFAULT_SIG) || (trap_list[sig] == (char *)IGNORE_SIG)) @@ -940,14 +944,20 @@ run_interrupt_trap () /* Free all the allocated strings in the list of traps and reset the trap values to the default. Intended to be called from subshells that want to complete work done by reset_signal_handlers upon execution of a - subsequent `trap' command that changes a signal's disposition. */ + subsequent `trap' command that changes a signal's disposition. We need + to make sure that we duplicate the behavior of + reset_or_restore_signal_handlers and not change the disposition of signals + that are set to be ignored. */ void free_trap_strings () { register int i; for (i = 0; i < BASH_NSIG; i++) - free_trap_string (i); + { + if (trap_list[i] != (char *)IGNORE_SIG) + free_trap_string (i); + } trap_list[DEBUG_TRAP] = trap_list[EXIT_TRAP] = trap_list[ERROR_TRAP] = trap_list[RETURN_TRAP] = (char *)NULL; } |