NIST Biometric Evaluation Framework
Software components for biometric technology evaluations
Public Member Functions | Static Public Attributes | List of all members
BiometricEvaluation::Error::SignalManager Class Reference

A SignalManager object is used to handle signals that come from the operating system. More...

#include <be_error_signal_manager.h>

Public Member Functions

 SignalManager ()
 Construct a new SignalManager object with the default signal handling: SIGSEGV and SIGBUS. More...
 
 SignalManager (const sigset_t signalSet)
 Construct a new SignalManager object with the specified signal handling, no defaults. More...
 
void setSignalSet (const sigset_t signalSet)
 Set the signals this object will manage. More...
 
void clearSignalSet ()
 Clear all signal handling. More...
 
void setDefaultSignalSet ()
 Set the default signals this object will manage: SIGSEGV and SIGBUS. More...
 
bool sigHandled ()
 Indicate whether a signal was handled. More...
 
void start ()
 Start handling signals of the current signal set. More...
 
void stop ()
 Stop handling signals of the current signal set. More...
 
void setSigHandled ()
 Set a flag to indicate a signal was handled. More...
 
void clearSigHandled ()
 Clear the indication that a signal was handled. More...
 
void setEnabled (const bool enabled)
 Enable or disable signal handling. More...
 
bool isEnabled () const
 Check the enabled status of signal handling. More...
 

Static Public Attributes

static bool _canSigJump
 Flag indicating can jump after handling a signal. More...
 
static sigjmp_buf _sigJumpBuf
 The jump buffer used by the signal handler. More...
 

Detailed Description

A SignalManager object is used to handle signals that come from the operating system.

Applications typically do not invoke most methods of a SignalManager, except the setSignalSet(), setDefaultSignalSet(), and sigHandled(). An application wishing to just catch memory errors can simply construct a SignalManager object, and invoke sigHandled() at the end of the signal block to detect whether a signal was handled.

The BEGIN_SIGNAL_BLOCK macro sets up the jump block and tells the SignalManager object to start handling signals. Applications can call either setSignalSet() or setDefaultSignalSet() before invoking these macros to indicate which signals are to be handled.

The END_SIGNAL_BLOCK() macro clears the signal set, so from that point forward application code signals will be handled in the system's default manner until another signal block is created.

The ABORT_SIGNAL_MANAGER() macro also disables the watchdog timer but does not create the code point destination for the jump point. This macro should be used to disable a SignalManager object when the application is no longer interested in the signal handling.

Attention
The BEGIN_SIGNAL_BLOCK() macro must be paired with either the END_SIGNAL_BLOCK() macro or ABORT_SIGNAL_MANAGER() macro. Failure to do so may result in undefined behavior as an active SignalManager may be invoked, forcing a jump into an incompletely initialized function.

A SignalManager is passive (i.e. no signal handlers are installed) until that start() method is called, and becomes passive when stop() is invoked. The signals that are to be handled by the object are maitained as state, and the set of signals can be changed at any time, but are not in effect until start() is called.

Attention
The start(), stop(), setSigHandled() and clearSigHandled() methods are not meant to be used directly by applications, which should use the BEGIN_SIGNAL_BLOCK()/END_SIGNAL_BLOCK() macro pair.

Definition at line 96 of file be_error_signal_manager.h.

Constructor & Destructor Documentation

◆ SignalManager() [1/2]

BiometricEvaluation::Error::SignalManager::SignalManager ( )

Construct a new SignalManager object with the default signal handling: SIGSEGV and SIGBUS.

Exceptions
Error::StrategyErrorCould not register the signal handler.

◆ SignalManager() [2/2]

BiometricEvaluation::Error::SignalManager::SignalManager ( const sigset_t  signalSet)

Construct a new SignalManager object with the specified signal handling, no defaults.

Parameters
signalSet(in) The signal set; see sigaction(2), sigemptyset(3) and sigaddset(3).
Exceptions
Error::ParameterErrorOne of the signals in signalSet cannot be handled (SIGKILL, SIGSTOP.).

Member Function Documentation

◆ setSignalSet()

void BiometricEvaluation::Error::SignalManager::setSignalSet ( const sigset_t  signalSet)

Set the signals this object will manage.

Parameters
signalSet(in) The signal set; see sigaction(2), sigemptyset(3) and sigaddset(3).
Exceptions
Error::ParameterErrorOne of the signals in signalSet cannot be handled (SIGKILL, SIGSTOP.).

◆ clearSignalSet()

void BiometricEvaluation::Error::SignalManager::clearSignalSet ( )

Clear all signal handling.

◆ setDefaultSignalSet()

void BiometricEvaluation::Error::SignalManager::setDefaultSignalSet ( )

Set the default signals this object will manage: SIGSEGV and SIGBUS.

◆ sigHandled()

bool BiometricEvaluation::Error::SignalManager::sigHandled ( )

Indicate whether a signal was handled.

Returns
true if a signal was handled, false otherwise.

◆ start()

void BiometricEvaluation::Error::SignalManager::start ( )

Start handling signals of the current signal set.

Exceptions
Error::StrategyErrorCould not register the signal handler.
Note
If an application invokes start() without setting up a signal jump block, behavior is undefined, and can result in an infinite loop if further processing causes a signal to be raised.

◆ stop()

void BiometricEvaluation::Error::SignalManager::stop ( )

Stop handling signals of the current signal set.

Exceptions
Error::StrategyErrorCould not register the signal handler.

◆ setSigHandled()

void BiometricEvaluation::Error::SignalManager::setSigHandled ( )

Set a flag to indicate a signal was handled.

◆ clearSigHandled()

void BiometricEvaluation::Error::SignalManager::clearSigHandled ( )

Clear the indication that a signal was handled.

◆ setEnabled()

void BiometricEvaluation::Error::SignalManager::setEnabled ( const bool  enabled)

Enable or disable signal handling.

Parameters
enabledtrue if enabled, false otherwise.
Note
This enables easier debugging without changing sourcecode to remove SignalManager blocks.

◆ isEnabled()

bool BiometricEvaluation::Error::SignalManager::isEnabled ( ) const

Check the enabled status of signal handling.

Member Data Documentation

◆ _canSigJump

bool BiometricEvaluation::Error::SignalManager::_canSigJump
static

Flag indicating can jump after handling a signal.

Note
Should not be directly used by applications.

Definition at line 210 of file be_error_signal_manager.h.

◆ _sigJumpBuf

sigjmp_buf BiometricEvaluation::Error::SignalManager::_sigJumpBuf
static

The jump buffer used by the signal handler.

Note
Should not be directly used by applications.

Definition at line 215 of file be_error_signal_manager.h.


The documentation for this class was generated from the following file: