#ifndef LIB_SIGNALS_H
#define LIB_SIGNALS_H
#include <signal.h>
enum libsig_flags {
/* Signal handler will be called later from IO loop when it's safe to
do any kind of work */
/* Restart syscalls instead of having them fail with EINTR */
/* Don't automatically shift delayed signal handling for this signal
to a newly started ioloop. */
};
/* Number of times a "termination signal" has been received.
These signals are SIGINT, SIGQUIT and SIGTERM. Callers can compare this to
their saved previous value to see if a syscall returning EINTR should be
treated as someone wanting to end the process or just some internal signal
that should be ignored, such as SIGCHLD.
This is marked as volatile so that compiler won't optimize away its
comparisons. It may not work perfectly everywhere, such as when accessing it
isn't atomic, so you shouldn't heavily rely on its actual value. */
extern volatile unsigned int signal_term_counter;
/* Convert si_code to string */
void lib_signals_ioloop_detach(void);
void lib_signals_ioloop_attach(void);
/* Set signal handler for specific signal. */
ATTR_NULL(4);
/* Ignore given signal. */
void lib_signals_unset_handler(int signo,
ATTR_NULL(3);
/* Switch ioloop for a specific signal handler created with
LIBSIG_FLAG_NO_IOLOOP_AUTOMOVE. */
void lib_signals_switch_ioloop(int signo,
/* Log a syscall error inside a (non-delayed) signal handler where i_error() is
unsafe. errno number will be appended to the prefix. */
void lib_signals_syscall_error(const char *prefix);
void lib_signals_init(void);
void lib_signals_deinit(void);
#endif