function
at_quick_exit
<cstdlib>
extern "C" int at_quick_exit ( void ( * func ) (void) ) noexcept;
extern "C++" int at_quick_exit ( void ( * func ) (void) ) noexcept;
Set function to be executed on quick exit
The function pointed by func is automatically called without arguments when quick_exit is called.
If more than one at_quick_exit function has been specified by different calls to this function, they are all executed in reverse order. Although notice that if called from more than one thread, the relative order may be indeterminate.
If at_quick_exit is called after quick_exit, the call may or may not succeed depending on the particular system and library implementation (unspecified behavior).
If a function registered with at_quick_exit throws an exception for which it does not provide a handler, terminate is automatically called (C++).
Notice that the at_quick_exit stack of functions is separate from the atexit stack (and each is triggered by different circumstances), but the same function may be passed to both functions so that it is called in both cases.
No data races are introduced by this function (C++).
Particular library implementations may impose a limit on the number of functions that can be registered with a_quick_exit, but this cannot be less than 32 functions.
Parameters
- function
- Function to be called. The function shall return no value and take no arguments.
Return Value
A zero value is returned if the function was successfully registered.
If it failed, a non-zero value is returned.
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
/* at_quick_exit example */
#include <stdio.h>
#include <stdlib.h>
void fnQExit (void)
{
puts ("Quick exit function.");
}
int main ()
{
at_quick_exit (fnQExit);
puts ("Main function: Beginning");
quick_exit (EXIT_SUCCESS);
puts ("Main function: End"); // never executed
return 0;
}
|
Output:
Main function: Beginning
Quick exit function.
|
See also
- atexit
- Set function to be executed on exit (function
)
- quick_exit
- Terminate calling process quick (function
)
- abort
- Abort current process (function
)