Rudiments
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
signalhandler Class Reference

#include <signalclasses.h>

Inherits object.

Public Member Functions

 signalhandler ()
 
 ~signalhandler ()
 
void setHandler (void(*handler)(int32_t))
 
bool handleSignal (int32_t signum)
 
bool handleSignal (int32_t signum, signalhandler *oldhandler)
 
void removeAllFlags ()
 
void addFlag (int32_t flag)
 
void removeFlag (int32_t flag)
 
int32_t getFlags ()
 
void setMask (signalset *sset)
 
const signalsetgetMask ()
 
- Public Member Functions inherited from object
virtual ~object ()
 

Static Public Member Functions

static bool supportsSignalHandlerParameter ()
 

Public Attributes

void(*)(int32_t) getHandler ()
 

Detailed Description

The signalhandler class provides methods for catching and handling signals.

Constructor & Destructor Documentation

◆ signalhandler()

signalhandler::signalhandler ( )

Creates an instance of the signalhandler class.

◆ ~signalhandler()

signalhandler::~signalhandler ( )

Deletes this instance of the signalhandler class.

Member Function Documentation

◆ addFlag()

void signalhandler::addFlag ( int32_t flag)

Add "flag" to the set of flags modifying the behavior of this signal handler.

◆ getFlags()

int32_t signalhandler::getFlags ( )

Returns the set of flags modifying the behavior of this signal handler.

◆ getMask()

const signalset * signalhandler::getMask ( )

Returns the current signal mask.

◆ handleSignal() [1/2]

bool signalhandler::handleSignal ( int32_t signum)

Instructs the program to handle "signum" by calling the handler set previously in setHandler(). May be called multiple times to associate the same handler with several signals.

Returns true on success and false on failure.

◆ handleSignal() [2/2]

bool signalhandler::handleSignal ( int32_t signum,
signalhandler * oldhandler )

Instructs the program to handle "signum" by calling the handler set previously in setHandler(). May be called multiple times to associate the same handler with several signals. Populates oldhandler with the values that were used to handle this signal prior to this call.

Returns true on success and false on failure.

◆ removeAllFlags()

void signalhandler::removeAllFlags ( )

Remove all signal flags.

◆ removeFlag()

void signalhandler::removeFlag ( int32_t flag)

Remove "flag" from the set of flags modifying the behavior of this signal handler.

◆ setHandler()

void signalhandler::setHandler ( void(*)(int32_t) handler)

Sets the function to call when the process receives the signal.

◆ setMask()

void signalhandler::setMask ( signalset * sset)

Explicitly sets the mask to "sset".

◆ supportsSignalHandlerParameter()

static bool signalhandler::supportsSignalHandlerParameter ( )
static

The function that you pass into setHandler() must have a void (*)(int32_t) signature.

However, on some platforms, the native signal handling frameworks do not actually pass the signal into the signal handler in this parameter. As a result, on those platforms, inside the signal handler, the parameter will have an undefined value and must be ignored.

This method will return true if the platform's native signal handling framework passes anything into the parameter and false otherwise.

Member Data Documentation

◆ getHandler

void(*)(int32_t) signalhandler::getHandler()

Returns a pointer to the function that will be called when the process receives the signal.