CI: update FreeBSD, NetBSD, OpenBSD, Solaris actions
[xz.git] / src / xz / signals.h
blob629335d4c96b1f68b7148389f12d9d621ec10e85
1 // SPDX-License-Identifier: 0BSD
3 ///////////////////////////////////////////////////////////////////////////////
4 //
5 /// \file signals.h
6 /// \brief Handling signals to abort operation
7 //
8 // Author: Lasse Collin
9 //
10 ///////////////////////////////////////////////////////////////////////////////
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;
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);
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);
32 /// Unblock the signals blocked by signals_block().
33 extern void signals_unblock(void);
34 #endif
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