]>
Commit | Line | Data |
---|---|---|
726f6388 JA |
1 | /* quit.h -- How to handle SIGINT gracefully. */ |
2 | ||
3 | /* Copyright (C) 1993 Free Software Foundation, Inc. | |
4 | ||
5 | This file is part of GNU Bash, the Bourne Again SHell. | |
6 | ||
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. | |
11 | ||
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. | |
16 | ||
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 | |
bb70624e | 19 | Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ |
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_ */ |