]>
Commit | Line | Data |
---|---|---|
726f6388 JA |
1 | /* quit.h -- How to handle SIGINT gracefully. */ |
2 | ||
3185942a | 3 | /* Copyright (C) 1993-2009 Free Software Foundation, Inc. |
726f6388 JA |
4 | |
5 | This file is part of GNU Bash, the Bourne Again SHell. | |
6 | ||
3185942a JA |
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 | |
3185942a JA |
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 | |
3185942a JA |
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 (_QUIT_H_) |
22 | #define _QUIT_H_ | |
726f6388 JA |
23 | |
24 | /* Non-zero means SIGINT has already ocurred. */ | |
0628567a JA |
25 | extern volatile int interrupt_state; |
26 | extern volatile int terminating_signal; | |
27 | ||
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) | |
726f6388 | 38 | |
ccc6cda3 JA |
39 | #define SETINTERRUPT interrupt_state = 1 |
40 | #define CLRINTERRUPT interrupt_state = 0 | |
41 | ||
42 | #define ADDINTERRUPT interrupt_state++ | |
43 | #define DELINTERRUPT interrupt_state-- | |
44 | ||
0628567a JA |
45 | /* The same sort of thing, this time just for signals that would ordinarily |
46 | cause the shell to terminate. */ | |
47 | ||
48 | #define CHECK_TERMSIG \ | |
49 | do { \ | |
50 | if (terminating_signal) termsig_handler (terminating_signal); \ | |
51 | } while (0) | |
52 | ||
ccc6cda3 | 53 | #endif /* _QUIT_H_ */ |