]> git.ipfire.org Git - thirdparty/bash.git/blame - trap.h
bash-4.4 beta release
[thirdparty/bash.git] / trap.h
CommitLineData
726f6388
JA
1/* trap.h -- data structures used in the trap mechanism. */
2
73a146be 3/* Copyright (C) 1993-2013 Free Software Foundation, Inc.
726f6388
JA
4
5 This file is part of GNU Bash, the Bourne Again SHell.
6
2e4498b3
CR
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.
726f6388 11
2e4498b3
CR
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.
726f6388 16
2e4498b3
CR
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/>.
19*/
726f6388 20
ccc6cda3
JA
21#if !defined (_TRAP_H_)
22#define _TRAP_H_
726f6388
JA
23
24#include "stdc.h"
25
26#if !defined (SIG_DFL)
d166f048 27#include "bashtypes.h"
726f6388
JA
28#include <signal.h>
29#endif /* SIG_DFL */
30
31#if !defined (NSIG)
32#define NSIG 64
33#endif /* !NSIG */
34
35#define NO_SIG -1
d3a24ed2
CR
36#define DEFAULT_SIG SIG_DFL
37#define IGNORE_SIG SIG_IGN
726f6388 38
ccc6cda3 39/* Special shell trap names. */
d3a24ed2
CR
40#define DEBUG_TRAP NSIG
41#define ERROR_TRAP NSIG+1
42#define RETURN_TRAP NSIG+2
43#define EXIT_TRAP 0
ccc6cda3 44
f73dda09 45/* system signals plus special bash traps */
d3a24ed2 46#define BASH_NSIG NSIG+3
f73dda09 47
d3a24ed2 48/* Flags values for decode_signal() */
39feef01 49#define DSIG_SIGPREFIX 0x01 /* don't allow `SIG' PREFIX */
d3a24ed2
CR
50#define DSIG_NOCASE 0x02 /* case-insensitive comparison */
51
64419627
CR
52/* A value which can never be the target of a trap handler. */
53#define IMPOSSIBLE_TRAP_HANDLER (SigHandler *)initialize_traps
54
d3a24ed2 55#define signal_object_p(x,f) (decode_signal (x,f) != NO_SIG)
726f6388 56
f73dda09
JA
57#define TRAP_STRING(s) \
58 (signal_is_trapped (s) && signal_is_ignored (s) == 0) ? trap_list[s] \
59 : (char *)NULL
60
ccc6cda3 61extern char *trap_list[];
726f6388
JA
62
63/* Externally-visible functions declared in trap.c. */
64extern void initialize_traps __P((void));
d3a24ed2 65
726f6388 66extern void run_pending_traps __P((void));
d3a24ed2 67
278286c9 68extern void queue_sigchld_trap __P((int));
726f6388 69extern void maybe_set_sigchld_trap __P((char *));
ed35cb4a 70extern void set_impossible_sigchld_trap __P((void));
726f6388 71extern void set_sigchld_trap __P((char *));
d3a24ed2 72
ccc6cda3 73extern void set_debug_trap __P((char *));
f73dda09 74extern void set_error_trap __P((char *));
d3a24ed2
CR
75extern void set_return_trap __P((char *));
76
0385211b 77extern void maybe_set_debug_trap __P((char *));
54a5fbe1
CR
78extern void maybe_set_error_trap __P((char *));
79extern void maybe_set_return_trap __P((char *));
0385211b 80
ccc6cda3 81extern void set_sigint_trap __P((char *));
726f6388 82extern void set_signal __P((int, char *));
d3a24ed2 83
726f6388
JA
84extern void restore_default_signal __P((int));
85extern void ignore_signal __P((int));
86extern int run_exit_trap __P((void));
ccc6cda3 87extern void run_trap_cleanup __P((int));
d3a24ed2 88extern int run_debug_trap __P((void));
f73dda09 89extern void run_error_trap __P((void));
d3a24ed2
CR
90extern void run_return_trap __P((void));
91
726f6388
JA
92extern void free_trap_strings __P((void));
93extern void reset_signal_handlers __P((void));
94extern void restore_original_signals __P((void));
95
73a146be 96extern void get_original_signal __P((int));
e502b4e0
CR
97extern void get_all_original_signals __P((void));
98
726f6388
JA
99extern char *signal_name __P((int));
100
d3a24ed2 101extern int decode_signal __P((char *, int));
de608191 102extern void run_interrupt_trap __P((int));
726f6388 103extern int maybe_call_trap_handler __P((int));
9e51a74d 104extern int signal_is_special __P((int));
726f6388 105extern int signal_is_trapped __P((int));
d42cb8c1 106extern int signal_is_pending __P((int));
726f6388 107extern int signal_is_ignored __P((int));
9e51a74d 108extern int signal_is_hard_ignored __P((int));
67440bc5 109extern void set_signal_hard_ignored __P((int));
ccc6cda3 110extern void set_signal_ignored __P((int));
f75912ae 111extern int signal_in_progress __P((int));
726f6388 112
55a5a4ac
CR
113extern int first_pending_trap __P((void));
114extern int any_signals_trapped __P((void));
115extern void check_signals_and_traps __P((void));
116
ccc6cda3 117#endif /* _TRAP_H_ */