In all C applications, the atexit list is honored only
after all condition handling activity has taken place and all user
code is removed from the stack, which invalidates any jump buffer
previously established.
With C, you can register a number of routines that gain control
during the termination of an enclave. When using the C
atexit() function,
consider the following:
- A C atexit routine can nominate only C routines, but
those routines can call routines written in other languages.
- User-written condition handlers can be registered while running
an atexit routine. However, any jump buffers established
are invalid.
- If a severity 2 or greater condition arises while running an atexit routine
and it is unhandled, further atexit routines are skipped
and the Language Environment environment is terminated.
- A C exit() function or PL/I STOP or EXIT statement
issued within an atexit routine halts all other atexit functions.
- If, while running an atexit routine, an attempt to
register another atexit routine is made, the registration
is ignored. The atexit routine returns a nonzero result
indicating a failure to register the routine.
C++ supports atexit(), but any function pointer input
to atexit() must be declared as having extern "C" linkage.