]> icculus.org git repositories - icculus/xz.git/blob - src/xz/signals.h
Cleanups to the code that detects the amount of RAM and
[icculus/xz.git] / src / xz / signals.h
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 /// \file       signals.h
4 /// \brief      Handling signals to abort operation
5 //
6 //  Copyright (C) 2007-2009 Lasse Collin
7 //
8 //  This program is free software; you can redistribute it and/or
9 //  modify it under the terms of the GNU Lesser General Public
10 //  License as published by the Free Software Foundation; either
11 //  version 2.1 of the License, or (at your option) any later version.
12 //
13 //  This program is distributed in the hope that it will be useful,
14 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
15 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 //  Lesser General Public License for more details.
17 //
18 ///////////////////////////////////////////////////////////////////////////////
19
20 /// If this is true, we will clean up the possibly incomplete output file,
21 /// return to main() as soon as practical. That is, the code needs to poll
22 /// this variable in various places.
23 extern volatile sig_atomic_t user_abort;
24
25
26 /// Initialize the signal handler, which will set user_abort to true when
27 /// user e.g. presses C-c.
28 extern void signals_init(void);
29
30
31 #ifndef _WIN32
32
33 /// Block the signals which don't have SA_RESTART and which would just set
34 /// user_abort to true. This is handy when we don't want to handle EINTR
35 /// and don't want SA_RESTART either.
36 extern void signals_block(void);
37
38 /// Unblock the signals blocked by signals_block().
39 extern void signals_unblock(void);
40
41 /// If user has sent us a signal earlier to terminate the process,
42 /// re-raise that signal to actually terminate the process.
43 extern void signals_exit(void);
44
45 #else
46
47 #define signals_block() do { } while (0)
48 #define signals_unblock() do { } while (0)
49 #define signals_exit() do { } while (0)
50
51 #endif