1 ///////////////////////////////////////////////////////////////////////////////
4 /// \brief Handling signals to abort operation
6 // Author: Lasse Collin
8 // This file has been put into the public domain.
9 // You can do whatever you want with this file.
11 ///////////////////////////////////////////////////////////////////////////////
13 /// If this is true, we will clean up the possibly incomplete output file,
14 /// return to main() as soon as practical. That is, the code needs to poll
15 /// this variable in various places.
16 extern volatile sig_atomic_t user_abort;
19 /// Initialize the signal handler, which will set user_abort to true when
20 /// user e.g. presses C-c.
21 extern void signals_init(void);
24 #if defined(_WIN32) || defined(__VMS)
25 # define signals_block() do { } while (0)
26 # define signals_unblock() do { } while (0)
28 /// Block the signals which don't have SA_RESTART and which would just set
29 /// user_abort to true. This is handy when we don't want to handle EINTR
30 /// and don't want SA_RESTART either.
31 extern void signals_block(void);
33 /// Unblock the signals blocked by signals_block().
34 extern void signals_unblock(void);
38 # define signals_exit() do { } while (0)
40 /// If user has sent us a signal earlier to terminate the process,
41 /// re-raise that signal to actually terminate the process.
42 extern void signals_exit(void);