1 /* quit.h -- How to handle SIGINT gracefully. */
3 /* Copyright (C) 1993-2009 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 (_QUIT_H_)
24 /* Non-zero means SIGINT has already ocurred. */
25 extern volatile int interrupt_state
;
26 extern volatile int terminating_signal
;
28 /* Macro to call a great deal. SIGINT just sets the interrupt_state variable.
29 When it is safe, put QUIT in the code, and the "interrupt" will take
30 place. The same scheme is used for terminating signals (e.g., SIGHUP)
31 and the terminating_signal variable. That calls a function which will
32 end up exiting the shell. */
35 if (terminating_signal) termsig_handler (terminating_signal); \
36 if (interrupt_state) throw_to_top_level (); \
39 #define SETINTERRUPT interrupt_state = 1
40 #define CLRINTERRUPT interrupt_state = 0
42 #define ADDINTERRUPT interrupt_state++
43 #define DELINTERRUPT interrupt_state--
45 /* The same sort of thing, this time just for signals that would ordinarily
46 cause the shell to terminate. */
48 #define CHECK_TERMSIG \
50 if (terminating_signal) termsig_handler (terminating_signal); \