Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
atexit, onexit
◄Summary► ◄Example► ◄Up► ◄Contents► ◄Index► ◄Back►
────────────────────────────────────────────────────────────────────────────
The atexit and onexit functions are passed the address of a
function (<func>) to be called when the program terminates
normally. Successive calls to these functions create a register
of functions that are executed "last in, first out." No more than
32 functions can be registered; a NULL is returned if the number
of functions exceeds 32. The functions passed cannot take
parameters.
The atexit function conforms to the ANSI standard and should be
used instead of onexit where ANSI portability is desired.
In the OS/2 environment, the atexit function calls the OS/2
function DosExitList. Also, all routines passed to atexit or
onexit should have the _loadds attribute if used in multithread
dynamic-link libraries.
Return Value
The atexit function returns 0 if successful, or a nonzero value if
an error occurs (e.g., if there are already 32 exit functions
defined).
The onexit function returns a pointer to the function if
successful, and returns NULL if there is no space left to store
the function pointer.
-♦-