Function iox::posix::registerSignalHandler

Function Documentation

SignalGuard iox::posix::registerSignalHandler(const Signal signal, const SignalHandlerCallback_t callback) noexcept

Register a callback for a specific posix signal (SIG***).

Attention

if a signal callback was already registered for the provided signal with registerSignalHandler or with sigaction() or signal(), the signal callback is overridden until the SignalGuard goes out of scope and restores the previous callback. If you override the callbacks multiple times and the created SignalGuards goes out of scope in a different order then the callback is restored which was active when the last SignalGuard which is going out of scope was created.

Parameters:
  • Signal[in] the signal to which the callback should be attached

  • callback[in] the callback which should be called when the signal is raised.

Returns:

SignalGuard, when it goes out of scope the previous signal action is restored.