iceoryx_hoofs 2.0.8
Loading...
Searching...
No Matches
iox::posix::SignalWatcher Class Reference

The SignalWatcher waits for SIGINT and SIGTERM. One can wait until the signal has occurred or ask the watcher if it has occurred. More...

#include <iceoryx_hoofs/posix_wrapper/signal_watcher.hpp>

Public Member Functions

 SignalWatcher (const SignalWatcher &)=delete
 SignalWatcher (SignalWatcher &&)=delete
SignalWatcher & operator= (const SignalWatcher &)=delete
SignalWatcher & operator= (SignalWatcher &&)=delete
void waitForSignal () const noexcept
 Blocks until either SIGTERM or SIGINT has occurred.
bool wasSignalTriggered () const noexcept
 Returns true when SIGTERM or SIGINT has occurred, otherwise false.

Static Public Member Functions

static SignalWatcher & getInstance () noexcept
 Returns the singleton instance of the SignalWatcher.

Friends

void internalSignalHandler (int) noexcept

Detailed Description

The SignalWatcher waits for SIGINT and SIGTERM. One can wait until the signal has occurred or ask the watcher if it has occurred.

// can be used to loop until SIGINT or SIGTERM has occurred
#include <iceoryx_hoofs/posix/signal_watcher.hpp>
void loopUntilTerminationRequested()
{
while(!iox::posix::hasTerminationRequested())
{
// your algorithm
}
}
// another possibility is to block until SIGINT or SIGTERM has occurred
void blockUntilCtrlC() {
// your objects which spawn threads
iox::posix::waitForTerminationRequest();
}

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