atexit()

NAME

atexit() - register a function to be called on exit

SYNOPSIS

#include <stdlib.h>

int atexit (void (*function)(void))

DESCRIPTION

The atexit(3) function registers the given function to be called at program exit, whether through exit(3) or through return from the program's main(). Functions so registered are called in reverse order; no arguments are passed. At least 32 functions can always be registered, and more are allowed as long as sufficient memory can be allocated.

RETURN VALUES

On success, the atexit(3) function returns 0; on failure, it returns -1 and sets the value of errno

ERRORS

atexit(3) can generate the following error:

[ENOMEM]
No memory was available to add the function to the list. The existing list of functions is unmodified.

SEE ALSO

exit(3)