C Language and Libraries Help (clang.hlp) (Table of Contents; Topic list)
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, _fatexit, _onexit, _fonexit
 Summary Example                         Up Contents Index Back
─────Run-Time Library───────────────────────────────────────────────────────
 
     The atexit and _onexit functions are passed the address of a
     function (<func>) to be called when a program terminates normally.
     Successive calls to either function create a register of functions
     that are executed in LIFO (last-in─first-out) order; no more than
     32 functions can be registered. The functions passed to atexit and
     _onexit cannot take parameters.
 
     For DOS32X, atexit and _onexit use the heap to hold the "register
     of functions." Thus, the number of functions that can be
     registered is limited only by heap memory.
 
     The _fatexit and _fonexit functions are far versions of atexit
     and _onexit, respectively. They can be used with any memory model.
 
     Return Value
 
     Both atexit and _fatexit return 0 if successful, or a nonzero
     value if an error occurs (e.g., if there are already 32 exit
     functions defined).
 
     Both _onexit and _fonexit return pointers to the function if
     successful, and return NULL if there is no space left to store the
     function pointer.
                                    -♦-