Rudiments: signalhandler Class Reference

Rudiments

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

## 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 () const
void | setMask (const signalset *sset)
const signalset * | getMask () const

## Static Public Member Functions
static bool | isSignalHandlerIntUsed ()

## 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 | ( |  | ) | const

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

## ◆ getMask()

const signalset* signalhandler::getMask | ( |  | ) | const

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.

## ◆ isSignalHandlerIntUsed()

static bool signalhandler::isSignalHandlerIntUsed | ( |  | ) |
| static

The function that you pass into setHandler() must have a void (*)(int32_t) signature. However, the native signal handling frameworks on some systems do not allow the signal number to be passed to the handler in the int32_t parameter. As a result, on those platforms, inside the signal handler, the paramer must be ignored.

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

## ◆ 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 | ( | const signalset * | sset | ) |

Explicitly sets the mask to "sset".

## 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.