1 /* trap.h -- data structures used in the trap mechanism. */
3 /* Copyright (C) 1993-2013 Free Software Foundation, Inc.
5 This file is part of GNU Bash, the Bourne Again SHell.
7 Bash is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 Bash is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Bash. If not, see <http://www.gnu.org/licenses/>.
21 #if !defined (_TRAP_H_)
26 #if !defined (SIG_DFL)
27 #include "bashtypes.h"
36 #define DEFAULT_SIG SIG_DFL
37 #define IGNORE_SIG SIG_IGN
39 /* Special shell trap names. */
40 #define DEBUG_TRAP NSIG
41 #define ERROR_TRAP NSIG+1
42 #define RETURN_TRAP NSIG+2
45 /* system signals plus special bash traps */
46 #define BASH_NSIG NSIG+3
48 /* Flags values for decode_signal() */
49 #define DSIG_SIGPREFIX 0x01 /* don't allow `SIG' PREFIX */
50 #define DSIG_NOCASE 0x02 /* case-insensitive comparison */
52 /* A value which can never be the target of a trap handler. */
53 #define IMPOSSIBLE_TRAP_HANDLER (SigHandler *)initialize_traps
55 #define signal_object_p(x,f) (decode_signal (x,f) != NO_SIG)
57 #define TRAP_STRING(s) \
58 (signal_is_trapped (s) && signal_is_ignored (s) == 0) ? trap_list[s] \
61 extern char *trap_list[];
63 /* Externally-visible functions declared in trap.c. */
64 extern void initialize_traps __P((void));
66 extern void run_pending_traps __P((void));
68 extern void queue_sigchld_trap __P((int));
69 extern void maybe_set_sigchld_trap __P((char *));
70 extern void set_impossible_sigchld_trap __P((void));
71 extern void set_sigchld_trap __P((char *));
73 extern void set_debug_trap __P((char *));
74 extern void set_error_trap __P((char *));
75 extern void set_return_trap __P((char *));
77 extern void set_sigint_trap __P((char *));
78 extern void set_signal __P((int, char *));
80 extern void restore_default_signal __P((int));
81 extern void ignore_signal __P((int));
82 extern int run_exit_trap __P((void));
83 extern void run_trap_cleanup __P((int));
84 extern int run_debug_trap __P((void));
85 extern void run_error_trap __P((void));
86 extern void run_return_trap __P((void));
88 extern void free_trap_strings __P((void));
89 extern void reset_signal_handlers __P((void));
90 extern void restore_original_signals __P((void));
92 extern void get_original_signal __P((int));
93 extern void get_all_original_signals __P((void));
95 extern char *signal_name __P((int));
97 extern int decode_signal __P((char *, int));
98 extern void run_interrupt_trap __P((void));
99 extern int maybe_call_trap_handler __P((int));
100 extern int signal_is_special __P((int));
101 extern int signal_is_trapped __P((int));
102 extern int signal_is_pending __P((int));
103 extern int signal_is_ignored __P((int));
104 extern int signal_is_hard_ignored __P((int));
105 extern void set_signal_hard_ignored __P((int));
106 extern void set_signal_ignored __P((int));
107 extern int signal_in_progress __P((int));
109 extern int first_pending_trap __P((void));
110 extern int any_signals_trapped __P((void));
111 extern void check_signals_and_traps __P((void));
113 #endif /* _TRAP_H_ */