1 // SPDX-License-Identifier: 0BSD 2 3 /////////////////////////////////////////////////////////////////////////////// 4 // 5 /// \file signals.h 6 /// \brief Handling signals to abort operation 7 // 8 // Author: Lasse Collin 9 // 10 /////////////////////////////////////////////////////////////////////////////// 11 12 /// If this is true, we will clean up the possibly incomplete output file, 13 /// return to main() as soon as practical. That is, the code needs to poll 14 /// this variable in various places. 15 extern volatile sig_atomic_t user_abort; 16 17 18 /// Initialize the signal handler, which will set user_abort to true when 19 /// user e.g. presses C-c. 20 extern void signals_init(void); 21 22 23 #if (defined(_WIN32) && !defined(__CYGWIN__)) || defined(__VMS) 24 # define signals_block() do { } while (0) 25 # define signals_unblock() do { } while (0) 26 #else 27 /// Block the signals which don't have SA_RESTART and which would just set 28 /// user_abort to true. This is handy when we don't want to handle EINTR 29 /// and don't want SA_RESTART either. 30 extern void signals_block(void); 31 32 /// Unblock the signals blocked by signals_block(). 33 extern void signals_unblock(void); 34 #endif 35 36 #if defined(_WIN32) && !defined(__CYGWIN__) 37 # define signals_exit() do { } while (0) 38 #else 39 /// If user has sent us a signal earlier to terminate the process, 40 /// re-raise that signal to actually terminate the process. 41 extern void signals_exit(void); 42 #endif 43