diff options
| author | Jari Aalto <jari.aalto@cante.net> | 1998-04-17 19:52:44 +0000 |
|---|---|---|
| committer | Jari Aalto <jari.aalto@cante.net> | 2009-09-12 16:46:51 +0000 |
| commit | cce855bc5b117cb7ae70064131120687bc69fac0 (patch) | |
| tree | 39c7a4ec8f6d22ef03df74f2684e6a04fef10399 /trap.c | |
| parent | e8ce775db824de329b81293b4e5d8fbd65624528 (diff) | |
| download | bash-cce855bc5b117cb7ae70064131120687bc69fac0.tar.gz | |
Imported from ../bash-2.02.tar.gz.
Diffstat (limited to 'trap.c')
| -rw-r--r-- | trap.c | 28 |
1 files changed, 22 insertions, 6 deletions
@@ -21,17 +21,17 @@ #include "config.h" -#include <stdio.h> - #if defined (HAVE_UNISTD_H) # include <unistd.h> #endif #include "bashtypes.h" -#include "trap.h" - #include "bashansi.h" +#include <stdio.h> + +#include "trap.h" + #include "shell.h" #include "signames.h" #include "builtins/common.h" @@ -135,7 +135,13 @@ char * signal_name (sig) int sig; { - return ((sig > NSIG || sig < 0) ? "bad signal number" : signal_names[sig]); + char *ret; + + /* on cygwin32, signal_names[sig] could be null */ + ret = (sig > NSIG || sig < 0) ? "bad signal number" : signal_names[sig]; + if (ret == NULL) + ret = "unrecognized signal number"; + return ret; } /* Turn a string into a signal number, or a number into @@ -246,6 +252,8 @@ trap_handler (sig) } #if defined (JOB_CONTROL) && defined (SIGCHLD) + +#ifdef INCLUDE_UNUSED /* Make COMMAND_STRING be executed when SIGCHLD is caught. */ void set_sigchld_trap (command_string) @@ -253,6 +261,7 @@ set_sigchld_trap (command_string) { set_signal (SIGCHLD, command_string); } +#endif /* Make COMMAND_STRING be executed when SIGCHLD is caught iff the current SIGCHLD trap handler is DEFAULT_SIG. */ @@ -272,12 +281,14 @@ set_debug_trap (command) set_signal (DEBUG_TRAP, command); } +#ifdef INCLUDE_UNUSED void set_sigint_trap (command) char *command; { set_signal (SIGINT, command); } +#endif /* Reset the SIGINT handler so that subshells that are doing `shellsy' things, like waiting for command substitution or executing commands @@ -515,7 +526,10 @@ run_exit_trap () code = setjmp (top_level); if (code == 0) - parse_and_execute (trap_command, "exit trap", SEVAL_NONINT|SEVAL_NOHIST); + { + reset_parser (); + parse_and_execute (trap_command, "exit trap", SEVAL_NONINT|SEVAL_NOHIST); + } else if (code == EXITPROG) return (last_command_exit_value); else @@ -587,6 +601,7 @@ run_interrupt_trap () _run_trap_internal (SIGINT, "interrupt trap"); } +#ifdef INCLUDE_UNUSED /* Free all the allocated strings in the list of traps and reset the trap values to the default. */ void @@ -602,6 +617,7 @@ free_trap_strings () } trap_list[DEBUG_TRAP] = trap_list[EXIT_TRAP] = (char *)NULL; } +#endif /* Reset the handler for SIG to the original value. */ static void |
