int at_quick_exit (void (*func)(void));
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.
If a function registered with at_quick_exit throws an exception for which it does not provide a handler while called by quick_exit, 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.
Particular library implementations may impose a limit on the number of functions that can be registered with at_quick_exit, but this cannot be less than 32 functions.
- Function to be called. The function shall return no value and take no arguments.
A zero value is returned if the function was successfully registered.
If it failed, a non-zero value is returned.
/* at_quick_exit example */
#include <stdio.h> /* puts */
#include <stdlib.h> /* at_quick_exit, quick_exit, EXIT_SUCCESS */
void fnQExit (void)
puts ("Quick exit function.");
int main ()
puts ("Main function: Beginning");
puts ("Main function: End"); // never executed
Main function: Beginning
Quick exit function.
Concurrently calling this function introduces no data races: Calls are properly synchronized at the process level, although notice that the relative order of calls from different threads is indeterminate.
Calls to at_quick_exit that do not complete before a call to quick_exit may not succeed (depends on particular library implementation).
No-throw guarantee: this function never throws exceptions.
- Set function to be executed on exit (function
- Terminate calling process quick (function
- Abort current process (function