2009-02-05 08:12:57 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
/// \file signals.h
|
|
|
|
/// \brief Handling signals to abort operation
|
|
|
|
//
|
2009-04-13 10:27:40 +02:00
|
|
|
// Author: Lasse Collin
|
2009-02-05 08:12:57 +01:00
|
|
|
//
|
2009-04-13 10:27:40 +02:00
|
|
|
// This file has been put into the public domain.
|
|
|
|
// You can do whatever you want with this file.
|
2009-02-05 08:12:57 +01:00
|
|
|
//
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/// If this is true, we will clean up the possibly incomplete output file,
|
|
|
|
/// return to main() as soon as practical. That is, the code needs to poll
|
|
|
|
/// this variable in various places.
|
|
|
|
extern volatile sig_atomic_t user_abort;
|
|
|
|
|
|
|
|
|
|
|
|
/// Initialize the signal handler, which will set user_abort to true when
|
|
|
|
/// user e.g. presses C-c.
|
|
|
|
extern void signals_init(void);
|
|
|
|
|
|
|
|
|
2010-05-27 13:32:51 +02:00
|
|
|
#if (defined(_WIN32) && !defined(__CYGWIN__)) || defined(__VMS)
|
2009-09-19 08:47:30 +02:00
|
|
|
# define signals_block() do { } while (0)
|
|
|
|
# define signals_unblock() do { } while (0)
|
|
|
|
#else
|
2009-02-05 08:12:57 +01:00
|
|
|
/// Block the signals which don't have SA_RESTART and which would just set
|
|
|
|
/// user_abort to true. This is handy when we don't want to handle EINTR
|
|
|
|
/// and don't want SA_RESTART either.
|
|
|
|
extern void signals_block(void);
|
|
|
|
|
|
|
|
/// Unblock the signals blocked by signals_block().
|
|
|
|
extern void signals_unblock(void);
|
2009-09-19 08:47:30 +02:00
|
|
|
#endif
|
2009-02-05 08:12:57 +01:00
|
|
|
|
2010-05-27 13:32:51 +02:00
|
|
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
2009-09-19 08:47:30 +02:00
|
|
|
# define signals_exit() do { } while (0)
|
|
|
|
#else
|
2009-02-05 08:12:57 +01:00
|
|
|
/// If user has sent us a signal earlier to terminate the process,
|
|
|
|
/// re-raise that signal to actually terminate the process.
|
|
|
|
extern void signals_exit(void);
|
|
|
|
#endif
|