omni::application::signal_handler::detach

SYNOPSIS

Detaches a delegate from the underlying system signal handler.

top

DESCRIPTION

Detaching a specific delegate will stop that function from receiving system signal events. Detaching a delegate that has not been initially attached has no effect.

top

PARAMETERS

sig_func - The omni::application::signal_handler::callback function delegate to detach from the signal handler event.

top

RETURN VALUES

No return value.

top

ERRORS

No errors specific to this context.

top

CONSIDERATIONS

This function will only have an effect if you have explicitly called one of the omni::application::run functions to block the main thread until program completion.

top

PLATFORM SPECIFIC

On Windows based platforms, this will also detach from the system signal events (as described), as well as the console control handler.

top

NOTES

No additional notes.

top

EXAMPLE
#include <omni/application>

static volatile bool dorun = true;

void app_signal(int sig)
{
    std::cout << "Signal received: " << sig << std::endl;
    dorun = false;
}

void app_run()
{
    int count = 0;
    bool atch = true;
    while (dorun) {
        omni::sync::sleep(10); // small sleep
        if (atch && ++count > 10) {
            atch = false;
            omni::application::signal_handler::detach(&app_signal);
            std::cout << "Will not receive the signal on app_signal" << std::endl;
        }
    }
}

int main(int argc, char* argv[])
{
    omni::application::signal_handler::attach(&app_signal);
    return omni::application::run(&app_run);
}
Visit the examples page for more.

top