csignals.C File Reference

#include "Util/csignals.H"
#include <cstdio>
#include <signal.h>
#include "Util/log.H"
Include dependency graph for csignals.C:

Go to the source code of this file.

Defines

#define INSTALL_SIG_HANDLER(s, h)
#define CASE_SIGNAL_NAME(x)   case x: return #x

Functions

void catchsignals (volatile int *dest) throw ()
 Install signal handlers to catch non-fatal signals.
const char * signame (int num) throw ()
 Get a string name for a given signal number (e.g., "SIGINT", "SIGTERM").

Detailed Description

trivial wrapper for catching ANSI C signals

Definition in file csignals.C.


Define Documentation

#define INSTALL_SIG_HANDLER ( s,
 ) 
Value:
do {                                          \
    handler old = signal(s, 0);                 \
    if (old == SIG_DFL) signal(s, h);           \
    else                signal(s, old);         \
  } while (0)

Function Documentation

void catchsignals ( volatile int *  dest  )  throw ()

Install signal handlers to catch non-fatal signals.

Parameters:
dest Location where the number of a caught signal will be stored. This is marked as 'volatile' because it will be modified by signal handlers. Typically, applications will pass a pointer to a local int variable in to catchsignals(), and then check the value of that variable in each iteration through the main loop of the application, and taking steps to exit the application if the value becomes non-zero.

Note that catchsignals() only installs handlers for non-fatal signals (such as SIGHUP, SIGINT [control-c], SIGTERM [kill] and SIGALRM). The idea is that the user can interrupt an application that would otherwise be in an perpetual loop, but still give the application a chance to shut down cleanly (flushing open files, computing final stats, etc.). However, we don't trap more serious signals such as SIGQUIT, SIGABRT, SIGBUS, SIGFPE, SIGKILL, or SIGSEGV -- these usually represent a programming bug and/or the desire to generate a core dump, so catching the signal would avoid a core dump and hinder the ability to debug the context in which the signal was generated.

Definition at line 64 of file csignals.C.

Referenced by main(), Simulation::run(), and submain().

const char* signame ( int  num  )  throw ()

Get a string name for a given signal number (e.g., "SIGINT", "SIGTERM").

Definition at line 102 of file csignals.C.

Referenced by main(), Simulation::run(), and submain().

Generated on Sun May 8 08:42:52 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3