Function set_terminate_handler

Synopsis

#include "breeze/process/program.hpp"

void set_terminate_handler(void(*user_function)(int))

Description

Sets *user_function as the "terminate handler", i.e. as the function which is called, with the exit code as an argument, if there is a fatal error or if the user calls program::terminate(). This makes it possible for the user to avoid calling the default terminate handler, which is std::exit() (and thus to avoid not calling destructors of local objects), for example, by raising an exception with the argument, having taken the precaution to encapsulate the entire contents of main() with:

try {
    breeze::program::instance().set_terminate_handler(
                                    raise_int_exception ) ;
    // ...
} catch ( int exit_code ) {
    return exit_code ;
}
Note
The terminate handler should not return, or std::abort() will be called immediately after.

Source

Line 174 in breeze/process/program.hpp.