CMS 3D CMS Logo

lat::Signal Class Reference

Utilities for handling signals and fatal errors. More...

#include <Iguana/Utilities/classlib/utils/Signal.h>

List of all members.

Public Types

typedef bool(* FatalHook )(int sig, siginfo_t *info, void *x)
 Application hook to run in fatal().
typedef 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.
typedef void(* HandlerType )(int sig, siginfo_t *info, void *extra)
 Signal handler type.
typedef bool(* QuitHook )(int sig, siginfo_t *info, void *x)
 Application clean-up hook invoked before quit() exits from program termination signals (SIGHUP, SIGTERM or SIGQUIT).

Static Public Member Functions

static void block (const sigset_t *mask, bool sense)
static void block (int sig, bool sense)
static bool crashed (void)
static void dumpContext (IOFD fd, char *buf, const void *context)
static void dumpInfo (IOFD fd, char *buf, int sig, const siginfo_t *info)
static void dumpMemory (IOFD fd, char *buf, const void *data, size_t n)
static void fatal (int sig, siginfo_t *info, void *x)
static bool fatalDump (int sig, siginfo_t *info, void *x)
static int fatalLevel (void)
static HandlerType handle (int sig, HandlerType handler, const sigset_t *blockMask=0)
static void handleFatal (const char *applicationName=0, IOFD fd=IOFD_INVALID, FatalHook hook=0, FatalReturn mainreturn=0, unsigned options=FATAL_DEFAULT)
static IOFD handleFatalFd (void)
static FatalHook handleFatalHook (void)
static unsigned handleFatalOptions (void)
static FatalReturn handleFatalReturn (void)
static void handleQuit (QuitHook hook=0)
static QuitHook handleQuitHook (void)
static HandlerType handler (int sig, sigset_t *mask=0)
static void ignore (int sig)
static int kill (pid_t process, int sig)
static void mask (const sigset_t *mask, sigset_t *old=0)
static const char * name (int sig)
static void pending (sigset_t *mask)
static bool pending (int sig)
static int queue (pid_t process, int sig, void *value)
static int queue (pid_t process, int sig, int value=0)
static int queue (int sig, void *value)
static int queue (int sig, int value=0)
static void quit (int sig, siginfo_t *info, void *x)
static int raise (int sig)
static void revert (int sig)
static void suspend (const sigset_t *mask)
static int wait (const sigset_t *mask, siginfo_t *info=0, long msecs=-1)
static bool wait (int sig, siginfo_t *info=0, long msecs=-1)

Static Public Attributes

static const int FATAL_AUTO_EXIT = 256
 Option to make fatal() exit via quit().
static const int FATAL_DEFAULT
 Default options to handleFatal().
static const int FATAL_DUMP_CONTEXT = 128
 Option to make fataldump() (invoked by fatal()) to dump the machine context (registers etc.
static const int FATAL_DUMP_CORE = 8
 Option to make fatal() dump a core file before crashing.
static const int FATAL_DUMP_LIBS = 64
 Option to make fataldump() (invoked by fatal()) to dump the list of currently loaded shared libraries.
static const int FATAL_DUMP_SIG = 16
 Option to make fataldump() (invoked by fatal()) to dump the signal name (as reported by name()).
static const int FATAL_DUMP_STACK = 32
 Option to make fataldump() (invoked by fatal()) to dump stack backtrace for the offending code location.
static const int FATAL_ON_INT = 4
 Option to make SIGINT fatal.
static const int FATAL_ON_QUIT = 2
 Option to make SIGHUP, SIGTERM and SIGQUIT fatal instead of just quit() signals.
static const int USR1_DUMP_CORE = 1
 Option that instructs fatal() to call coredump() on SIGUSR1.

Static Private Member Functions

static const char * describe (int sig, int code)
static void trampoline (int sig)

Static Private Attributes

static const char * s_applicationName
static bool s_crashed
static IOFD s_fatalFd
static FatalHook s_fatalHook
static unsigned s_fatalOptions
static FatalReturn s_fatalReturn
static int s_inFatal
static QuitHook s_quitHook
static HandlerType s_trampolines [NSIG]


Detailed Description

Utilities for handling signals and fatal errors.

FIXME: POSIX single-threaded vs. multi-threaded signals?

The fatal error handling is largely inspired by code in DDD, the Data Display Debugger, and by the examples in GNU libc manual.

Definition at line 65 of file Signal.h.


Member Typedef Documentation

typedef bool(* lat::Signal::FatalHook)(int sig, siginfo_t *info, void *x)

Application hook to run in fatal().

The hook should return true if the signal handler should proceed to die. sig is the signal number, or its negative if core was dumped and, as far as can determined, successfully produced.

The fatal hooks should, if possible, perform clean-ups similar to QuitHook. The application may achieve this by actually using the quit by setting FATAL_AUTO_EXIT for handleFatal(), or it could reuse an internal function in both handlers.

typedef void(* lat::Signal::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.

It must never return. sig is the signal number, or its negative if core was dumped and, as far as can determined, successfully produced.

typedef void(* lat::Signal::HandlerType)(int sig, siginfo_t *info, void *extra)

Signal handler type.

This is defined explicitly and does not necessarily match the system's concept of signal handler type. If necessary, suitable trampolines are used internally to make sure the arguments make sense.

Parameters:
sig The signal number.
info Pointer to signal info. This pointer will be null on platforms that do not support POSIX signals.
extra Extra argument, e.g. the fault address. This pointer will be null on platforms that do not support POSIX signals.

typedef bool(* lat::Signal::QuitHook)(int sig, siginfo_t *info, void *x)

Application clean-up hook invoked before quit() exits from program termination signals (SIGHUP, SIGTERM or SIGQUIT).

The handler should return true if the signal handler should proceed to exit the application. Note that certain options to handlFatal() cause this hook to be invoked for fatal signals. If such behaviour is enabled, be sure to check the crashed() status before deciding to let the application to continue.

The quit hook should take care of resetting terminal modes, killing child processes, removing lock files, and so forth.


Member Function Documentation

static void lat::Signal::block ( const sigset_t mask,
bool  sense 
) [static]

static void lat::Signal::block ( int  sig,
bool  sense 
) [static]

static bool lat::Signal::crashed ( void   )  [static]

Referenced by IgQtAppCrashAlertService::hasCrashed(), and IgApplication::run().

static const char* lat::Signal::describe ( int  sig,
int  code 
) [static, private]

static void lat::Signal::dumpContext ( IOFD  fd,
char *  buf,
const void context 
) [static]

static void lat::Signal::dumpInfo ( IOFD  fd,
char *  buf,
int  sig,
const siginfo_t info 
) [static]

static void lat::Signal::dumpMemory ( IOFD  fd,
char *  buf,
const void data,
size_t  n 
) [static]

static void lat::Signal::fatal ( int  sig,
siginfo_t info,
void x 
) [static]

static bool lat::Signal::fatalDump ( int  sig,
siginfo_t info,
void x 
) [static]

Referenced by IgOnCrashService::defaultFatalSignal().

static int lat::Signal::fatalLevel ( void   )  [static]

static HandlerType lat::Signal::handle ( int  sig,
HandlerType  handler,
const sigset_t blockMask = 0 
) [static]

static void lat::Signal::handleFatal ( const char *  applicationName = 0,
IOFD  fd = IOFD_INVALID,
FatalHook  hook = 0,
FatalReturn  mainreturn = 0,
unsigned  options = FATAL_DEFAULT 
) [static]

Referenced by IgOnCrashService::init(), and VisQueueProcessor::process().

static IOFD lat::Signal::handleFatalFd ( void   )  [static]

static FatalHook lat::Signal::handleFatalHook ( void   )  [static]

static unsigned lat::Signal::handleFatalOptions ( void   )  [static]

static FatalReturn lat::Signal::handleFatalReturn ( void   )  [static]

static void lat::Signal::handleQuit ( QuitHook  hook = 0  )  [static]

static QuitHook lat::Signal::handleQuitHook ( void   )  [static]

static HandlerType lat::Signal::handler ( int  sig,
sigset_t mask = 0 
) [static]

static void lat::Signal::ignore ( int  sig  )  [static]

static int lat::Signal::kill ( pid_t  process,
int  sig 
) [static]

static void lat::Signal::mask ( const sigset_t mask,
sigset_t old = 0 
) [static]

static const char* lat::Signal::name ( int  sig  )  [static]

Referenced by IgOnCrashService::defaultFatalSignal().

static void lat::Signal::pending ( sigset_t mask  )  [static]

static bool lat::Signal::pending ( int  sig  )  [static]

static int lat::Signal::queue ( pid_t  process,
int  sig,
void value 
) [static]

static int lat::Signal::queue ( pid_t  process,
int  sig,
int  value = 0 
) [static]

static int lat::Signal::queue ( int  sig,
void value 
) [static]

static int lat::Signal::queue ( int  sig,
int  value = 0 
) [static]

static void lat::Signal::quit ( int  sig,
siginfo_t info,
void x 
) [static]

static int lat::Signal::raise ( int  sig  )  [static]

static void lat::Signal::revert ( int  sig  )  [static]

static void lat::Signal::suspend ( const sigset_t mask  )  [static]

static void lat::Signal::trampoline ( int  sig  )  [static, private]

static int lat::Signal::wait ( const sigset_t mask,
siginfo_t info = 0,
long  msecs = -1 
) [static]

static bool lat::Signal::wait ( int  sig,
siginfo_t info = 0,
long  msecs = -1 
) [static]


Member Data Documentation

const int lat::Signal::FATAL_AUTO_EXIT = 256 [static]

Option to make fatal() exit via quit().

This will cause all the appliction clean-up hook to run.

Definition at line 107 of file Signal.h.

const int lat::Signal::FATAL_DEFAULT [static]

Initial value:

Default options to handleFatal().

Definition at line 110 of file Signal.h.

const int lat::Signal::FATAL_DUMP_CONTEXT = 128 [static]

Option to make fataldump() (invoked by fatal()) to dump the machine context (registers etc.

) from the fault position.

Definition at line 103 of file Signal.h.

const int lat::Signal::FATAL_DUMP_CORE = 8 [static]

Option to make fatal() dump a core file before crashing.

Definition at line 87 of file Signal.h.

const int lat::Signal::FATAL_DUMP_LIBS = 64 [static]

Option to make fataldump() (invoked by fatal()) to dump the list of currently loaded shared libraries.

Definition at line 99 of file Signal.h.

const int lat::Signal::FATAL_DUMP_SIG = 16 [static]

Option to make fataldump() (invoked by fatal()) to dump the signal name (as reported by name()).

Definition at line 91 of file Signal.h.

const int lat::Signal::FATAL_DUMP_STACK = 32 [static]

Option to make fataldump() (invoked by fatal()) to dump stack backtrace for the offending code location.

Definition at line 95 of file Signal.h.

const int lat::Signal::FATAL_ON_INT = 4 [static]

Option to make SIGINT fatal.

It will still just quit, not crash.

Definition at line 84 of file Signal.h.

const int lat::Signal::FATAL_ON_QUIT = 2 [static]

Option to make SIGHUP, SIGTERM and SIGQUIT fatal instead of just quit() signals.

Definition at line 80 of file Signal.h.

const char* lat::Signal::s_applicationName [static, private]

Definition at line 232 of file Signal.h.

bool lat::Signal::s_crashed [static, private]

Definition at line 230 of file Signal.h.

IOFD lat::Signal::s_fatalFd [static, private]

Definition at line 233 of file Signal.h.

FatalHook lat::Signal::s_fatalHook [static, private]

Definition at line 234 of file Signal.h.

unsigned lat::Signal::s_fatalOptions [static, private]

Definition at line 236 of file Signal.h.

FatalReturn lat::Signal::s_fatalReturn [static, private]

Definition at line 235 of file Signal.h.

int lat::Signal::s_inFatal [static, private]

Definition at line 231 of file Signal.h.

QuitHook lat::Signal::s_quitHook [static, private]

Definition at line 237 of file Signal.h.

HandlerType lat::Signal::s_trampolines[NSIG] [static, private]

Definition at line 239 of file Signal.h.

const int lat::Signal::USR1_DUMP_CORE = 1 [static]

Option that instructs fatal() to call coredump() on SIGUSR1.

This is merely a request to drop a core; no attempt is made to guarantee success. Failure may result for example for lack of permissions, for lack of disk space, or due to low resource limits. Please note that core files can only be created on unixen. Note also that dropping a core is a security risk and should never be enabled in setuid or setgid programs or for production applications.

Definition at line 76 of file Signal.h.


The documentation for this class was generated from the following file:
Generated on Tue Jun 9 18:48:35 2009 for CMSSW by  doxygen 1.5.4