Patch-ID: bash32-044
[bash.git] / quit.h
bloba33543968a87c3926ff11e94bcdb15c7cdd58b03
1 /* quit.h -- How to handle SIGINT gracefully. */
3 /* Copyright (C) 1993 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 it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
10 version.
12 Bash is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
17 You should have received a copy of the GNU General Public License along
18 with Bash; see the file COPYING. If not, write to the Free Software
19 Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
21 #if !defined (_QUIT_H_)
22 #define _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. */
33 #define QUIT \
34 do { \
35 if (terminating_signal) termsig_handler (terminating_signal); \
36 if (interrupt_state) throw_to_top_level (); \
37 } while (0)
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 \
49 do { \
50 if (terminating_signal) termsig_handler (terminating_signal); \
51 } while (0)
53 #endif /* _QUIT_H_ */