atexit
(Designed for drivers) Creates a list of functions that are executed on a "last-in, first-out" basis when the NLM exits normally or is unloaded
#include <nwthread.h>
#include <stdlib.h>
int atexit (
void (* func) (void));
The following table lists return values and descriptions.
WARNING:The atexit function is designed to be used by drivers. Do not use it as an NLM cleanup routine. A server abend may result for this reason:
CLIB context does not exist for a thread that is running an atexit or AtUnload routine, since all NLM thread groups have been destroyed by the time these functions are called. Thus any saved thread group ID is invalid, and neither atexit nor AtUnload routines can use SetThreadGroupID to establish CLIB context for the thread. They therefore also cannot use NetWare API functions that require thread group or thread level context.
It is wise programing practice to have one exit point for a program, which could be the cleanup routine for the NLM. The "Remarks" section of AtUnload gives suggestions for developing a cleanup routine to be executed when an NLM is manually unloaded. The same routine can be used when exit is called from your program.
The atexit function is called when an NLM is terminated normally.
Successive calls to atexit create a list of functions that are executed on a "last-in, first-out" basis when:
No more than 32 functions can be registered with atexit. The functions have no parameters and do not return values. Such functions can use only NLM (OS) level context.