IDL maintains a list of exit handler functions that it calls as part of its shutdown operations. These handlers perform actions such as closing files, wrapping up graphics output, and restoring the user environment to its initial state. Exit handlers accept no arguments and return no value.

A typical declaration would be:

void my_exit_handler(void)
{
   /* Cleanup Code Here */
}

IDL_ExitRegister()


To register an exit handler, use the IDL_ExitRegister() function:

void IDL_ExitRegister(IDL_EXIT_HANDLER_FUNC)

where IDL_EXIT_HANDLER_FUNC is defined as:

typedef void(* IDL_EXIT_HANDLER_FUNC)(void);

proc

IDL will call proc just before it exits.

The order in which exit handlers are called is undefined, and you should not depend on any particular ordering. If you have several exit handlers and the order in which they are called is important, you should register a single handler that calls all the others in the required order.

Note: Under some operating systems, it is possible that the IDL process will die in an abnormal way that prevents the calling of the exit handlers. For example, under UNIX, receiving some signals (possibly via the kill(1) command) will cause the process to die immediately. IDL always calls exit handlers when possible, so this is rarely a significant problem.

Please note that any user-created DLM using IDL_ExitRegister() will crash if the callback is not unregistered on a .full_reset. Calling IDL_ExitRegister(&test_exit_callback); requires

cx_public void IDL_ResetSession(void)
{
   IDL_ExitUnregister(&test_exit_callback);
}