iceoryx_hoofs 2.0.3
Public Member Functions | Static Public Member Functions | Friends | List of all members
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
 
SignalWatcheroperator= (const SignalWatcher &)=delete
 
SignalWatcheroperator= (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 SignalWatchergetInstance () 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: