omni::application::last_signal
NAME

omni::application::last_signal

A function of omni::application

#include <omni/application.hpp>
int omni::application::last_signal()

SYNOPSIS

Gets the last signal received by this application.

top

DESCRIPTION

If a call to an omni::application::run context has been made and a signal is received (e.g. SIGABRT or SIGSEGV), this function will return the last signal received.

top

RETURN VALUES

The integer value of the last signal received.

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

The number value returned can vary between platforms for the different signals. For example, SIGINT on Windows has the value of 0 while on some *nix systems, the value is 2, which might lead to confusion expecting a 0 value to mean a SUCCESS value. To this, if you are checking the signal value for a specific value, be sure to check against the specific signal itself, i.e. if (omni::application::last_signal() == SIGINT)

top


EXAMPLE

#include <omnilib>

static volatile bool dorun = true;

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

void app_run()
{
    while (dorun) {
        omni::sync::sleep(10); // small sleep
    }
}

int main(int argc, const char* argv[])
{
    omni::application::signal_handler::attach(&app_signal);
    int ret = omni::application::run(&app_run);
    std::cout << "Last signal: " << omni::application::last_signal() << std::endl;
    return ret;
}
Visit the examples page for more.

top