2016-05-03 20:02:26 +00:00
|
|
|
// The library for various signal related issues.
|
2006-10-29 21:09:11 +00:00
|
|
|
#ifndef FISH_SIGNALH
|
|
|
|
#define FISH_SIGNALH
|
2005-10-06 07:30:50 +00:00
|
|
|
|
2012-08-15 07:57:56 +00:00
|
|
|
#include <signal.h>
|
|
|
|
|
2016-05-03 20:02:26 +00:00
|
|
|
/// Get the integer signal value representing the specified signal, or -1 of no signal was found.
|
2012-11-19 00:30:30 +00:00
|
|
|
int wcs2sig(const wchar_t *str);
|
2005-10-06 07:30:50 +00:00
|
|
|
|
2016-05-03 20:02:26 +00:00
|
|
|
/// Get string representation of a signal.
|
2012-11-19 00:30:30 +00:00
|
|
|
const wchar_t *sig2wcs(int sig);
|
2005-10-06 07:30:50 +00:00
|
|
|
|
2016-05-03 20:02:26 +00:00
|
|
|
/// Returns a description of the specified signal.
|
2012-11-19 00:30:30 +00:00
|
|
|
const wchar_t *signal_get_desc(int sig);
|
2005-10-06 07:30:50 +00:00
|
|
|
|
2016-05-03 20:02:26 +00:00
|
|
|
/// Set all signal handlers to SIG_DFL.
|
2005-10-06 11:54:16 +00:00
|
|
|
void signal_reset_handlers();
|
|
|
|
|
2016-05-03 20:02:26 +00:00
|
|
|
/// Set signal handlers to fish default handlers.
|
2019-05-27 21:52:48 +00:00
|
|
|
void signal_set_handlers(bool interactive);
|
|
|
|
|
|
|
|
/// Latch function. This sets signal handlers, but only the first time it is called.
|
|
|
|
void signal_set_handlers_once(bool interactive);
|
2005-10-06 11:54:16 +00:00
|
|
|
|
2016-05-03 20:02:26 +00:00
|
|
|
/// Tell fish what to do on the specified signal.
|
|
|
|
///
|
|
|
|
/// \param sig The signal to specify the action of
|
2019-06-28 17:33:03 +00:00
|
|
|
void signal_handle(int sig);
|
2005-10-14 11:40:33 +00:00
|
|
|
|
2017-05-03 03:55:41 +00:00
|
|
|
/// Ensure we did not inherit any blocked signals. See issue #3964.
|
|
|
|
void signal_unblock_all();
|
|
|
|
|
2016-05-03 20:02:26 +00:00
|
|
|
/// Returns signals with non-default handlers.
|
2012-08-15 07:57:56 +00:00
|
|
|
void get_signals_with_handlers(sigset_t *set);
|
2018-10-02 18:20:48 +00:00
|
|
|
|
2019-05-26 02:05:24 +00:00
|
|
|
/// A sigint_detector_t can be used to check if a SIGINT (or SIGHUP) has been delivered.
|
|
|
|
class sigint_checker_t {
|
|
|
|
uint64_t gen_{0};
|
|
|
|
|
|
|
|
public:
|
|
|
|
sigint_checker_t();
|
|
|
|
|
|
|
|
/// Check if a sigint has been delivered since the last call to check(), or since the detector
|
|
|
|
/// was created.
|
|
|
|
bool check();
|
2019-05-26 02:19:03 +00:00
|
|
|
|
|
|
|
/// Wait until a sigint is delivered.
|
|
|
|
void wait();
|
2019-05-26 02:05:24 +00:00
|
|
|
};
|
|
|
|
|
2006-10-29 21:09:11 +00:00
|
|
|
#endif
|