Skip to content

iox::posix::SignalWatcher🔗

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 Functions🔗

Name
SignalWatcher(const SignalWatcher & )
SignalWatcher(SignalWatcher && )
~SignalWatcher() =default
SignalWatcher & operator=(const SignalWatcher & )
SignalWatcher & operator=(SignalWatcher && )
void waitForSignal() const
Blocks until either SIGTERM or SIGINT has occurred.
bool wasSignalTriggered() const
Returns true when SIGTERM or SIGINT has occurred, otherwise false.
SignalWatcher & getInstance()
Returns the singleton instance of the SignalWatcher.

Protected Functions🔗

Name
SignalWatcher()

Friends🔗

Name
void internalSignalHandler(int )

Detailed Description🔗

class iox::posix::SignalWatcher;

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();
}

Public Functions Documentation🔗

function SignalWatcher🔗

SignalWatcher(
    const SignalWatcher & 
)

function SignalWatcher🔗

SignalWatcher(
    SignalWatcher && 
)

function ~SignalWatcher🔗

~SignalWatcher() =default

function operator=🔗

SignalWatcher & operator=(
    const SignalWatcher & 
)

function operator=🔗

SignalWatcher & operator=(
    SignalWatcher && 
)

function waitForSignal🔗

void waitForSignal() const

Blocks until either SIGTERM or SIGINT has occurred.

function wasSignalTriggered🔗

bool wasSignalTriggered() const

Returns true when SIGTERM or SIGINT has occurred, otherwise false.

function getInstance🔗

static SignalWatcher & getInstance()

Returns the singleton instance of the SignalWatcher.

Protected Functions Documentation🔗

function SignalWatcher🔗

SignalWatcher()

Friends🔗

friend internalSignalHandler🔗

friend void internalSignalHandler(
    int 
);

Updated on 17 March 2022 at 12:15:57 CET