2016-05-04 04:02:26 +08:00
|
|
|
// The library for various signal related issues.
|
2006-10-30 05:09:11 +08:00
|
|
|
#ifndef FISH_SIGNALH
|
|
|
|
#define FISH_SIGNALH
|
2005-10-06 15:30:50 +08:00
|
|
|
|
2012-08-15 15:57:56 +08:00
|
|
|
#include <signal.h>
|
|
|
|
|
2016-05-04 04:02:26 +08:00
|
|
|
/// Get the integer signal value representing the specified signal, or -1 of no signal was found.
|
2012-11-19 08:30:30 +08:00
|
|
|
int wcs2sig(const wchar_t *str);
|
2005-10-06 15:30:50 +08:00
|
|
|
|
2016-05-04 04:02:26 +08:00
|
|
|
/// Get string representation of a signal.
|
2012-11-19 08:30:30 +08:00
|
|
|
const wchar_t *sig2wcs(int sig);
|
2005-10-06 15:30:50 +08:00
|
|
|
|
2016-05-04 04:02:26 +08:00
|
|
|
/// Returns a description of the specified signal.
|
2012-11-19 08:30:30 +08:00
|
|
|
const wchar_t *signal_get_desc(int sig);
|
2005-10-06 15:30:50 +08:00
|
|
|
|
2016-05-04 04:02:26 +08:00
|
|
|
/// Set all signal handlers to SIG_DFL.
|
2005-10-06 19:54:16 +08:00
|
|
|
void signal_reset_handlers();
|
|
|
|
|
2016-05-04 04:02:26 +08:00
|
|
|
/// Set signal handlers to fish default handlers.
|
2019-06-25 17:16:48 +08:00
|
|
|
void signal_set_handlers();
|
2005-10-06 19:54:16 +08:00
|
|
|
|
2016-05-04 04:02:26 +08:00
|
|
|
/// Tell fish what to do on the specified signal.
|
|
|
|
///
|
|
|
|
/// \param sig The signal to specify the action of
|
2019-06-29 01:33:03 +08:00
|
|
|
void signal_handle(int sig);
|
2005-10-14 19:40:33 +08:00
|
|
|
|
2017-05-03 11:55:41 +08:00
|
|
|
/// Ensure we did not inherit any blocked signals. See issue #3964.
|
|
|
|
void signal_unblock_all();
|
|
|
|
|
2016-05-04 04:02:26 +08:00
|
|
|
/// Returns signals with non-default handlers.
|
2012-08-15 15:57:56 +08:00
|
|
|
void get_signals_with_handlers(sigset_t *set);
|
2018-10-03 02:20:48 +08:00
|
|
|
|
2019-05-26 10:05:24 +08: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 10:19:03 +08:00
|
|
|
|
|
|
|
/// Wait until a sigint is delivered.
|
|
|
|
void wait();
|
2019-05-26 10:05:24 +08:00
|
|
|
};
|
|
|
|
|
2006-10-30 05:09:11 +08:00
|
|
|
#endif
|