1 ///////////////////////////////////////////////////////////////////////////////
4 /// \brief Handling signals to abort operation
6 // Copyright (C) 2007-2009 Lasse Collin
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Lesser General Public
10 // License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
18 ///////////////////////////////////////////////////////////////////////////////
20 /// If this is true, we will clean up the possibly incomplete output file,
21 /// return to main() as soon as practical. That is, the code needs to poll
22 /// this variable in various places.
23 extern volatile sig_atomic_t user_abort;
26 /// Initialize the signal handler, which will set user_abort to true when
27 /// user e.g. presses C-c.
28 extern void signals_init(void);
33 /// Block the signals which don't have SA_RESTART and which would just set
34 /// user_abort to true. This is handy when we don't want to handle EINTR
35 /// and don't want SA_RESTART either.
36 extern void signals_block(void);
38 /// Unblock the signals blocked by signals_block().
39 extern void signals_unblock(void);
41 /// If user has sent us a signal earlier to terminate the process,
42 /// re-raise that signal to actually terminate the process.
43 extern void signals_exit(void);
47 #define signals_block() do { } while (0)
48 #define signals_unblock() do { } while (0)
49 #define signals_exit() do { } while (0)