|
ATLAS Offline Software
|
Go to the documentation of this file.
17 #ifndef CXXUTILS_SEAL_SIGNAL_H // wlav SEAL_BASE_SIGNAL_H
18 #define CXXUTILS_SEAL_SIGNAL_H // wlav SEAL_BASE_SIGNAL_H
28 # include <sys/types.h>
34 #ifdef si_utime // sss
35 # define HAVE_SIGINFO_SI_UTIME 1 // sss
38 # define HAVE_SIGINFO_SI_INT 1 // sss
40 # if !HAVE_SIGINFO_SI_UTIME // darwin
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 // darwin
46 # define si_int si_value.sigval_int
47 # define si_ptr si_value.sigval_ptr
48 # else // (none known)
49 # define si_int si_signo ? 0 : 0
50 # define si_ptr si_signo ? (void *) 0 : (void *) 0
55 # if !HAVE_POSIX_SIGNALS
61 typedef 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);
210 static void block (
int sig,
bool sense);
215 static int raise (
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);
282 #if !HAVE_POSIX_SIGNALS
299 #endif // CXXUTILS_SEAL_SIGNAL_H wlav SEAL_BASE_SIGNAL_H
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)
static const char * s_applicationName
The current application name.
char data[hepevt_bytes_allocation_ATLAS]
static IOFD s_fatalFd
The output file descriptor for #fataldump().
static const int FATAL_DUMP_STACK
Option to make #fataldump(int, siginfo_t *, void *) (invoked by #fatal(int, siginfo_t *,...
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 bool s_crashed
Indicator that the application has been crashed: that a fatal signal has been delivered.
static IOFD handleFatalFd ATLAS_NOT_THREAD_SAFE(void)
static unsigned s_fatalOptions
The current fatal signal handling options.
static const int FATAL_DUMP_CORE
Option to make #fatal(int, siginfo_t *, void *) dump a core file before crashing.
static bool crashed ATLAS_NOT_THREAD_SAFE(void)
Collecting a few shared bits and pieces from SEAL headers.
static const int FATAL_DEFAULT
Default options to #handleFatal(const char *, IOFD fd, FatalHook, FatalReturn, unsigned.
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 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 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)
Utilities for handling signals and fatal errors.
static const int FATAL_ON_INT
Option to make SIGINT fatal.
static const int USR1_DUMP_CORE
Option that instructs #fatal(int, siginfo_t *, void *) to call #coredump() on SIGUSR1.
static const int FATAL_DUMP_SIG
Option to make #fataldump(int, siginfo_t *, void *) (invoked by #fatal(int, siginfo_t *,...
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).
void CxxUtils_installFatalHandler ATLAS_NOT_THREAD_SAFE()
Install fatal handler with default options.
Some weak symbol referencing magic...
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 ignore(int sig)
Ignore the signal number sig.
int IOFD
Type the system uses for channel descriptors.
static QuitHook s_quitHook
The application handler hook for quitting-related signals.
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.
void(* HandlerType)(int sig, siginfo_t *info, void *extra)
Signal handler type.
static const int FATAL_DUMP_LIBS
Option to make #fataldump(int sig, siginfo_t *, void *) (invoked by #fatal(int, siginfo_t *,...
static int queue(int sig, int value=0)
Queue signal sig for this process with additional data value.
static const int FATAL_DUMP_CONTEXT
Option to make #fataldump(int, siginfo_t *, void *) (invoked by #fatal(int, siginfo_t *,...
static const char * name(int sig)
Return the name of the signal number sig.
static const int FATAL_AUTO_EXIT
Option to make #fatal(int, siginfo_t *, void *) exit via #quit(int , siginfo_t *, void *).
static std::atomic< unsigned long > s_lastSP
Used to switch to a raw stack dump if we crash during a backtrace.
static bool fatalDump ATLAS_NOT_THREAD_SAFE(int sig, siginfo_t *info, void *x, IOFD fd, unsigned options)
static const int FATAL_ON_QUIT
Option to make SIGHUP, SIGTERM and SIGQUIT fatal instead of just #quit(int , siginfo_t *,...
#define IOFD_INVALID
Invalid channel descriptor constant.
static void trampoline(int sig)
Internal signal handler trampoline to convert handler arguments to look more like POSIX signals.
static FatalHook s_fatalHook
The application handler hook for fatal signals.
static void handleQuit ATLAS_NOT_THREAD_SAFE(QuitHook hook=0)
static void block(int sig, bool sense)
Block or unblock the signal number sig.
static bool fatalDump 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.
bool(* FatalHook)(int sig, siginfo_t *info, void *x)
Application hook to run in fatal().
static FatalReturn s_fatalReturn
The application main return hook for fatal signals.
static unsigned handleFatalOptions ATLAS_NOT_THREAD_SAFE(void)
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 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 void quit ATLAS_NOT_THREAD_SAFE(int sig, siginfo_t *info, void *x)
static FatalReturn handleFatalReturn ATLAS_NOT_THREAD_SAFE(void)
bool(* QuitHook)(int sig, siginfo_t *info, void *x)
Application clean-up hook invoked before #quit(int , siginfo_t *, void *) exits from program terminat...
static void revert(int sig)
Revert the signal number sig back to its default behaviour.
Define macros for attributes used to control the static checker.
setBGCode setTAP setLVL2ErrorBits bool
static int s_inFatal
Indicator that we are currently executing inside #fatal().
static QuitHook handleQuitHook ATLAS_NOT_THREAD_SAFE(void)
static void fatal ATLAS_NOT_THREAD_SAFE(int sig, siginfo_t *info, void *x)
static int kill(pid_t process, int sig)
Send the signal sig to process identified by process.
static bool pending(int sig)
Check if sig is pending for this process.
static HandlerType s_trampolines[NSIG]
Actual signal handlers when POSIX signals are not available.
static int fatalLevel ATLAS_NOT_THREAD_SAFE(void)