SYNOPSIS
Exits the main application with a specified return value.
top
Exits the main application with a specified return value.
#include <omni/application.hpp>
void omni::application::exit(int exit_status)
top
DESCRIPTION
If
top
If
omni::application::run has been called and is blocking, exit will signal the underlying run function to continue thus calling any shutdown handlers attached via omni::application::shutdown_handler::attach, after which the delegates registered with the omni::application::exit_handler will be invoked finally calling std::exit after all handlers have been invoked, passing in the exit_status value.
top
PARAMETERS top
exit_status - The exit status value to pass to the underlying exit function system call.
EXAMPLE
top
#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; std::cout << "Running" << std::endl; while (dorun) { omni::sync::sleep(10); // small sleep if (++count > 100) { std::cout << "Calling exit" << std::endl; omni::application::exit(); } } } 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