ATEXITSection: Linux Programmer's Manual (3)Updated: 2003-11-01 |
ATEXITSection: Linux Programmer's Manual (3)Updated: 2003-11-01 |
#include <stdlib.h> int atexit(void (*function)(void));
At least ATEXIT_MAX functions can be registered. This value is at least 32. It can be obtained using sysconf(3).
By a successful call to one of the exec functions, all registrations are undone.
#include <stdio.h> #include <stdlib.h> #include <unistd.h> void bye(void) { printf("That was all, folks\n"); } int main(){ long a; int i; a = sysconf(_SC_ATEXIT_MAX); printf("ATEXIT_MAX = %ld\n", a); i = atexit(bye); if (i != 0) { fprintf(stderr, "cannot set exit function\n"); return EXIT_FAILURE; } return EXIT_SUCCESS; }