#include <BLSignal.hh>
SIGUSR1 and SIGUSR2 are special, and do not exit the program; they are merely reported via functions sigusr1() and sigusr2().
Note that a second received signal causes an immediate call to g4bl_exit() from the signal handler.
If BLAlarm is also used, BLSignal::init() must be called first.
Note that BLManager checks received() in UserSteppingAction(), and issues a fatal exception when any signal is received..
Public Member Functions | |
void | clear () |
clear() will clear the signalReceived flag. | |
Static Public Member Functions | |
static void | init () |
init() will setup the signal handler | |
static bool | received () |
received() returns true if a signal has been received. Does not include SIGUSR1 or SIGUSR2. Does not include SIGALRM if BLAlarm is used. | |
static int | value () |
value() returns the signal # of the last sginal received. Does not include SIGUSR1 or SIGUSR2. Does not include SIGALRM if BLAlarm is used. | |
static void | setSignalReceived (bool v) |
setSignalReceived() will set the signalReceived flag. | |
static bool | sigusr1 () |
sigusr1() returns true if one or more SIGUSR1 signals was received since the last call; | |
static bool | sigusr2 () |
sigusr2() returns true if one or more SIGUSR2 signals was received since the last call; | |
Static Private Member Functions | |
static void | sighandler (int sig) |
sighandler() handles the alarm signal | |
Static Private Attributes | |
static bool | signalReceived = false |
static bool | usr1 = false |
static bool | usr2 = false |
static int | prev = 0 |
void BLSignal::init | ( | ) | [static] |
init() will setup the signal handler
References prev, sighandler(), and signalReceived.
Referenced by BLManager::BLManager().
00047 { 00048 #ifdef WIN32 00049 static int sigs[] = {SIGINT, SIGILL, SIGABRT, 00050 SIGSEGV, SIGTERM, SIGFPE}; 00051 #else 00052 static int sigs[] = {SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGABRT, 00053 SIGKILL, SIGBUS, SIGSEGV, SIGSYS, SIGPIPE, SIGTERM, SIGXCPU, 00054 SIGUSR1, SIGUSR2}; 00055 #endif 00056 00057 signalReceived = false; 00058 prev = 0; 00059 00060 for(unsigned i=0; i<sizeof(sigs)/sizeof(sigs[0]); ++i) 00061 signal(sigs[i],sighandler); 00062 00063 #ifdef WIN32 00064 SetConsoleCtrlHandler( (PHANDLER_ROUTINE) CtrlHandler, TRUE ); 00065 #endif 00066 }
static bool BLSignal::received | ( | ) | [inline, static] |
received() returns true if a signal has been received. Does not include SIGUSR1 or SIGUSR2. Does not include SIGALRM if BLAlarm is used.
References signalReceived.
Referenced by BLManager::UserSteppingAction().
00044 { return signalReceived; };
static int BLSignal::value | ( | ) | [inline, static] |
value() returns the signal # of the last sginal received. Does not include SIGUSR1 or SIGUSR2. Does not include SIGALRM if BLAlarm is used.
References prev.
Referenced by BLManager::UserSteppingAction().
00049 { return prev; }
void BLSignal::clear | ( | ) | [inline] |
clear() will clear the signalReceived flag.
References prev, and signalReceived.
00052 { signalReceived = false; prev = 0; }
static void BLSignal::setSignalReceived | ( | bool | v | ) | [inline, static] |
setSignalReceived() will set the signalReceived flag.
References signalReceived.
Referenced by BLCommand::getNextCommand().
00055 { signalReceived = v; }
static bool BLSignal::sigusr1 | ( | ) | [inline, static] |
sigusr1() returns true if one or more SIGUSR1 signals was received since the last call;
References usr1.
Referenced by BLManager::EndOfEventAction().
static bool BLSignal::sigusr2 | ( | ) | [inline, static] |
void BLSignal::sighandler | ( | int | sig | ) | [static, private] |
sighandler() handles the alarm signal
References g4bl_exit(), prev, signalReceived, usr1, and usr2.
Referenced by init().
00069 { 00070 signal(sig,sighandler); 00071 00072 #ifndef WIN32 00073 if(sig == SIGUSR1) { 00074 usr1 = true; 00075 return; 00076 } 00077 if(sig == SIGUSR2) { 00078 usr2 = true; 00079 return; 00080 } 00081 #endif 00082 00083 if(signalReceived) { 00084 static bool moreThanTwo=false; 00085 if(moreThanTwo) 00086 _exit(99); 00087 moreThanTwo = true; 00088 fflush(stdout); 00089 fprintf(stderr, "\n" 00090 "***************************************************\n" 00091 "*** Multiple signals received (%d,%d), exiting ***\n" 00092 "***************************************************\n", 00093 prev,sig); 00094 g4bl_exit(99); 00095 } 00096 00097 prev = sig; 00098 signalReceived = true; 00099 }
bool BLSignal::signalReceived = false [static, private] |
Referenced by clear(), init(), received(), setSignalReceived(), and sighandler().
bool BLSignal::usr1 = false [static, private] |
Referenced by sighandler(), and sigusr1().
bool BLSignal::usr2 = false [static, private] |
Referenced by sighandler(), and sigusr2().
int BLSignal::prev = 0 [static, private] |
Referenced by clear(), init(), sighandler(), and value().