]> icculus.org git repositories - icculus/xz.git/blob - src/xz/signals.h
Put the interesting parts of XZ Utils into the public domain.
[icculus/xz.git] / src / xz / signals.h
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 #ifndef _WIN32
25
26 /// Block the signals which don't have SA_RESTART and which would just set
27 /// user_abort to true. This is handy when we don't want to handle EINTR
28 /// and don't want SA_RESTART either.
29 extern void signals_block(void);
30
31 /// Unblock the signals blocked by signals_block().
32 extern void signals_unblock(void);
33
34 /// If user has sent us a signal earlier to terminate the process,
35 /// re-raise that signal to actually terminate the process.
36 extern void signals_exit(void);
37
38 #else
39
40 #define signals_block() do { } while (0)
41 #define signals_unblock() do { } while (0)
42 #define signals_exit() do { } while (0)
43
44 #endif