17#ifndef CXXUTILS_SEAL_SIGNAL_H
18#define CXXUTILS_SEAL_SIGNAL_H
28# include <sys/types.h>
35# define HAVE_SIGINFO_SI_UTIME 1
38# define HAVE_SIGINFO_SI_INT 1
40# if !HAVE_SIGINFO_SI_UTIME
41# define si_utime si_signo ? 0 : 0
42# define si_stime si_signo ? 0 : 0
44# if !HAVE_SIGINFO_SI_INT
45# if HAVE_SIGINFO_SI_VALUE
46# define si_int si_value.sigval_int
47# define si_ptr si_value.sigval_ptr
49# define si_int si_signo ? 0 : 0
50# define si_ptr si_signo ? (void *) 0 : (void *) 0
55# if !HAVE_POSIX_SIGNALS
61typedef struct _EXCEPTION_RECORD
siginfo_t;
82# define sigemptyset(x) (0)
83# define sigfillset(x) (0)
84# define sigaddset(x,y) (0)
85# define sigdelset(x,y) (0)
86# define sigismember(x,y) (0)
201 static const char *
name (
int sig);
207 static void revert (
int sig);
208 static void ignore (
int sig);
210 static void block (
int sig,
bool sense);
215 static int raise (
int sig);
217 static int queue (
int sig,
int value = 0);
218 static int queue (
int sig,
void *value);
225 static bool wait (
int sig,
258 unsigned int buf_size,
262 unsigned int buf_size,
263 const void *
data,
size_t n);
265 unsigned int buf_size,
266 const void *context);
268 static const char *
describe (
int sig,
int code);
282#if !HAVE_POSIX_SIGNALS
char data[hepevt_bytes_allocation_ATLAS]
Collecting a few shared bits and pieces from SEAL headers.
#define IOFD_INVALID
Invalid channel descriptor constant.
int IOFD
Type the system uses for channel descriptors.
void CxxUtils_installFatalHandler ATLAS_NOT_THREAD_SAFE()
Install fatal handler with default options.
Define macros for attributes used to control the static checker.
Utilities for handling signals and fatal errors.
static QuitHook handleQuitHook ATLAS_NOT_THREAD_SAFE(void)
static HandlerType handler(int sig, sigset_t *mask=0)
Return the current handler for signal number sig and its blocked signals in mask (if non-null).
static FatalHook handleFatalHook ATLAS_NOT_THREAD_SAFE(void)
static unsigned s_fatalOptions
The current fatal signal handling options.
static int raise(int sig)
Raise the signal number sig.
static FatalReturn handleFatalReturn ATLAS_NOT_THREAD_SAFE(void)
static const int FATAL_DUMP_CONTEXT
Option to make fataldump(int, siginfo_t *, void *) (invoked by fatal(int, siginfo_t *,...
bool(* QuitHook)(int sig, siginfo_t *info, void *x)
Application clean-up hook invoked before quit(int , siginfo_t *, void *) exits from program terminati...
static const char * name(int sig)
Return the name of the signal number sig.
static const int FATAL_DEFAULT
Default options to handleFatal(const char *, IOFD fd, FatalHook, FatalReturn, unsigned.
static unsigned long dumpContext(IOFD fd, char *buf, unsigned int buf_size, const void *context)
Utility function to dump the process context, as obtained for instance through signal handler paramet...
static void suspend(const sigset_t *mask)
Temporarily replace the signal mask of the process with mask and then suspend until a signal is recei...
static const int FATAL_AUTO_EXIT
Option to make fatal(int, siginfo_t *, void *) exit via quit(int , siginfo_t *, void *).
static int kill(pid_t process, int sig)
Send the signal sig to process identified by process.
static void handleQuit ATLAS_NOT_THREAD_SAFE(QuitHook hook=0)
static IOFD s_fatalFd
The output file descriptor for fataldump().
static int queue(int sig, int value=0)
Queue signal sig for this process with additional data value.
static bool fatalDump ATLAS_NOT_THREAD_SAFE(int sig, siginfo_t *info, void *x)
static void quit ATLAS_NOT_THREAD_SAFE(int sig, siginfo_t *info, void *x)
static void fatal ATLAS_NOT_THREAD_SAFE(int sig, siginfo_t *info, void *x)
static const char * describe(int sig, int code)
Return the description for signal info code code for signal number sig.
static const int FATAL_ON_QUIT
Option to make SIGHUP, SIGTERM and SIGQUIT fatal instead of just quit(int , siginfo_t *,...
static bool crashed ATLAS_NOT_THREAD_SAFE(void)
static FatalReturn s_fatalReturn
The application main return hook for fatal signals.
bool(* FatalHook)(int sig, siginfo_t *info, void *x)
Application hook to run in fatal().
static void mask(const sigset_t *mask, sigset_t *old=0)
Set the list of currently blocked signals to mask and return the old setting in old (if non-null).
static void dumpMemory(IOFD fd, char *buf, unsigned int buf_size, const void *data, size_t n)
Utility function to dump memory section from data for n bytes.
static IOFD handleFatalFd ATLAS_NOT_THREAD_SAFE(void)
static const char * s_applicationName
The current application name.
static bool fatalDump ATLAS_NOT_THREAD_SAFE(int sig, siginfo_t *info, void *x, IOFD fd, unsigned options)
static int s_inFatal
Indicator that we are currently executing inside fatal().
static bool wait(int sig, siginfo_t *info=0, long msecs=-1)
Suspend the thread waiting for signal sig at most msecs milliseconds.
static void block(int sig, bool sense)
Block or unblock the signal number sig.
static FatalHook s_fatalHook
The application handler hook for fatal signals.
static const int FATAL_DUMP_CORE
Option to make fatal(int, siginfo_t *, void *) dump a core file before crashing.
static std::atomic< unsigned long > s_lastSP
Used to switch to a raw stack dump if we crash during a backtrace.
static void dumpInfo(IOFD fd, char *buf, unsigned int buf_size, int sig, const siginfo_t *info)
Utility function to dump the signal info descriptor for signal sig, as obtained for instance through ...
static unsigned handleFatalOptions ATLAS_NOT_THREAD_SAFE(void)
static void ignore(int sig)
Ignore the signal number sig.
static void revert(int sig)
Revert the signal number sig back to its default behaviour.
static bool s_crashed
Indicator that the application has been crashed: that a fatal signal has been delivered.
static bool pending(int sig)
Check if sig is pending for this process.
static const int FATAL_DUMP_LIBS
Option to make fataldump(int sig, siginfo_t *, void *) (invoked by fatal(int, siginfo_t *,...
static QuitHook s_quitHook
The application handler hook for quitting-related signals.
static const int USR1_DUMP_CORE
Option that instructs fatal(int, siginfo_t *, void *) to call coredump() on SIGUSR1.
static void trampoline(int sig)
Internal signal handler trampoline to convert handler arguments to look more like POSIX signals.
static int fatalLevel ATLAS_NOT_THREAD_SAFE(void)
static const int FATAL_DUMP_SIG
Option to make fataldump(int, siginfo_t *, void *) (invoked by fatal(int, siginfo_t *,...
void(* FatalReturn)(int sig, siginfo_t *info, void *x)
Application hook to jump back to the main program from a fatal signal, for example using siglongjmp.
static HandlerType handle(int sig, HandlerType handler, const sigset_t *blockMask=0)
Install a new signal handler handler for signal number sig and returns the old handler.
static const int FATAL_DUMP_STACK
Option to make fataldump(int, siginfo_t *, void *) (invoked by fatal(int, siginfo_t *,...
static HandlerType s_trampolines[NSIG]
Actual signal handlers when POSIX signals are not available.
static void handleFatal ATLAS_NOT_THREAD_SAFE(const char *applicationName=0, IOFD fd=IOFD_INVALID, FatalHook hook=0, FatalReturn mainreturn=0, unsigned options=FATAL_DEFAULT)
void(* HandlerType)(int sig, siginfo_t *info, void *extra)
Signal handler type.
static const int FATAL_ON_INT
Option to make SIGINT fatal.
const std::string process
Some weak symbol referencing magic... These are declared in AthenaKernel/getMessageSvc....
static char buf[SIGNAL_MESSAGE_BUFSIZE]
Dump application state information on a fatal signal.