The SignalGuard is a class returned by registerSignalHandler. When it goes out of scope it restores the previous signal action. Typical use case: One would like to override the signal action in main() or some C posix makes it necessary to override the standard signal action before and after the call.
More...
#include <iceoryx_hoofs/posix_wrapper/signal_handler.hpp>
The SignalGuard is a class returned by registerSignalHandler. When it goes out of scope it restores the previous signal action. Typical use case: One would like to override the signal action in main() or some C posix makes it necessary to override the standard signal action before and after the call.
- Attention
- NEVER USE THIS CLASS AS A MEMBER VARIABLE! A class which should be used only in method/function scopes.
{
my_c_call_which_can_cause_SIGBUS();
}
friend SignalGuard registerSignalHandler(const Signal, const SignalHandlerCallback_t) noexcept
Register a callback for a specific posix signal (SIG***).
◆ registerSignalHandler
SignalGuard registerSignalHandler |
( |
const |
Signal, |
|
|
const |
SignalHandlerCallback_t |
|
) |
| |
|
friend |
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
-
[in] | Signal | the signal to which the callback should be attached |
[in] | callback | 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.
The documentation for this class was generated from the following file: