Registers a function to be called when the virtual machine (VM) exits or unloads.
#include <nks/vm.h> int NXVmRegisterExitHandler ( void (*cleanup) (void *), void *arg);
(IN) Points to the address of the function to be invoked at program exit.
(IN) Points to the parameter to pass to the handler when it starts.
If successful, returns zero; otherwise, returns an error:
NXVmRegisterExitHandler associates a cleanup function with the calling application's VM so that the registered function gets called when the application exits. The value in arg is passed to it.
Subsequent calls result in chaining the cleanup handler to the next most recent. The order of invocation of these handlers is last-in, first-out (LIFO).
The cleanup function should be used for true cleanup needs of applications and libraries and not for common housekeeping chores.
Do not spend more time in cleanup functions than is absolutely necessary. While a function may block, it may be pulled from execution if it takes too long (this is an arbitrary time limit).
Cleanup handlers are called whenever the application unloads, regardless of the condition that caused the unload.