atexit(2) CLIX atexit(2)
NAME
atexit - Registers a function to be called at program termination
LIBRARY
Standard C Library (libc.a)
SYNOPSIS
#include <stdlib.h>
int atexit(
void (*func)(void) );
PARAMETERS
func Points to a function to be called when the program terminates
normally.
DESCRIPTION
Each call to the atexit() function stores the address of the function
func() to be called when the program terminates normally. If the program
terminates normally, each function is called in a last-in-first-out order.
EXAMPLES
In this example, if the value returned by atexit() is -1, the message
failed to register myfunc appears.
#include <stdlib.h>
if (atexit(myfunc) == -1)
perror("failed to register myfunc");
RETURN VALUES
Upon successful completion, atexit() returns a value of 0. If atexit()
fails, (typically only on a malloc() failure) a value of -1 is returned.
RELATED INFORMATION
Functions: exit(2)
2/94 - Intergraph Corporation 1