atexit
register a function to be called on exit
You're viewing an older version of this page (#3233). View the current version.
NAME
<span class="Nm" id="atexit">atexit</span>
INTERFACE
#include <stdlib.h> int atexit ( void (*function)(void) )
DESCRIPTION
The atexit function registers the given \c function to be called at program exit, whether via exit (3) or via return from the program's main . Functions so registered are called in reverse order; no arguments are passed. \n \n These functions must not call exit ; if it should be necessary to terminate the process while in such a function, the reference:_exit (2) function should be used. (Alternatively, the function may cause abnormal process termination, for example by calling abort (3) .) \n \n At least 32 functions can always be registered, and more are allowed as long as sufficient memory can be allocated.
RETURN VALUES
<span class="Rv">-std</span> <span class="Rv">atexit</span>
ERRORS
<table cellspacing="0" class="refpage" style="margin-left:25px"> <tr> <td valign="top" nowrap> [<span class="Bq"><span class="Er">ENOMEM</span></span>] </td> <td valign="top"> No memory was available to add the function to the list. The existing list of functions is unmodified. </td> </tr> </table>
SEE ALSO
exit (3)
STANDARDS
The atexit function conforms to