1207753Smm/////////////////////////////////////////////////////////////////////////////// 2207753Smm// 3207753Smm/// \file signals.h 4207753Smm/// \brief Handling signals to abort operation 5207753Smm// 6207753Smm// Author: Lasse Collin 7207753Smm// 8207753Smm// This file has been put into the public domain. 9207753Smm// You can do whatever you want with this file. 10207753Smm// 11207753Smm/////////////////////////////////////////////////////////////////////////////// 12207753Smm 13207753Smm/// If this is true, we will clean up the possibly incomplete output file, 14207753Smm/// return to main() as soon as practical. That is, the code needs to poll 15207753Smm/// this variable in various places. 16207753Smmextern volatile sig_atomic_t user_abort; 17207753Smm 18207753Smm 19207753Smm/// Initialize the signal handler, which will set user_abort to true when 20207753Smm/// user e.g. presses C-c. 21207753Smmextern void signals_init(void); 22207753Smm 23207753Smm 24213700Smm#if (defined(_WIN32) && !defined(__CYGWIN__)) || defined(__VMS) 25207753Smm# define signals_block() do { } while (0) 26207753Smm# define signals_unblock() do { } while (0) 27207753Smm#else 28207753Smm/// Block the signals which don't have SA_RESTART and which would just set 29207753Smm/// user_abort to true. This is handy when we don't want to handle EINTR 30207753Smm/// and don't want SA_RESTART either. 31207753Smmextern void signals_block(void); 32207753Smm 33207753Smm/// Unblock the signals blocked by signals_block(). 34207753Smmextern void signals_unblock(void); 35207753Smm#endif 36207753Smm 37213700Smm#if defined(_WIN32) && !defined(__CYGWIN__) 38207753Smm# define signals_exit() do { } while (0) 39207753Smm#else 40207753Smm/// If user has sent us a signal earlier to terminate the process, 41207753Smm/// re-raise that signal to actually terminate the process. 42207753Smmextern void signals_exit(void); 43207753Smm#endif 44