1 /////////////////////////////////////////////////////////////////////////////// 2 // 3 /// \file signals.h 4 /// \brief Handling signals to abort operation 5 // 6 // Author: Lasse Collin 7 // 8 // This file has been put into the public domain. 9 // You can do whatever you want with this file. 10 // 11 /////////////////////////////////////////////////////////////////////////////// 12 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; 17 18 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); 22 23 24 #if (defined(_WIN32) && !defined(__CYGWIN__)) || defined(__VMS) 25 # define signals_block() do { } while (0) 26 # define signals_unblock() do { } while (0) 27 #else 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); 32 33 /// Unblock the signals blocked by signals_block(). 34 extern void signals_unblock(void); 35 #endif 36 37 #if defined(_WIN32) && !defined(__CYGWIN__) 38 # define signals_exit() do { } while (0) 39 #else 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); 43 #endif 44