The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group

 NAME

atexit - register a function to run at process termination

 SYNOPSIS



#include <stdlib.h>

int atexit(void (*func)(void));

 DESCRIPTION

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.

 RETURN VALUE

Upon successful completion, atexit() returns 0. Otherwise, it returns a non-zero value.

 ERRORS

No errors are defined.

 EXAMPLES

None.

 APPLICATION USAGE

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().

 FUTURE DIRECTIONS

None.

 SEE ALSO

exit(), sysconf(), <stdlib.h>.

DERIVATION

Derived from the ANSI C standard.

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]