omni::application::set_return_code

SYNOPSIS

Sets the value returned from an omni::application::run function or the exit status passed if omni::application::stop is called.

top

DESCRIPTION

The return value of the omni::application::run functions can be explicitly set via set_return_code as well this function set the exit status code returned should omni::application::stop be called.

top

PARAMETERS

return_code - The integer value to return.

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 or explicitly call omni::application::stop.

top

PLATFORM SPECIFIC

Nothing platform specific to account for.

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;
    omni::application::set_return_code(1);
    dorun = false;
}

void app_run()
{
    omni::application::set_return_code(-1);
    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 << "Return code: " << ret << std::endl;
    return ret;
}
Visit the examples page for more.

top