atexit - register a function to run at process termination
#include <stdlib.h> int atexit(void (*func)(void));
The atexit() function registers the function pointed to by func to be called without arguments. At normal process termination, functions registered by atexit() are called in the reverse order to that in which they were registered. Normal termination occurs either by a call to exit() or a return from main().At least 32 functions can be registered with atexit().
After a successful call to any of the exec functions, any functions previously registered by atexit() are no longer registered.
Upon successful completion, atexit() returns 0. Otherwise, it returns a non-zero value.
No errors are defined.
None.
The functions registered by a call to atexit() must return to ensure that all registered functions are called.The application should call sysconf() to obtain the value of {ATEXIT_MAX}, the number of functions that can be registered. There is no way for an application to tell how many functions have already been registered with atexit().
None.
exit(), sysconf(), <stdlib.h>.
Derived from the ANSI C standard.