An exit callback function is a function that gawk calls before it exits. Such functions are useful if you have general “clean up” tasks that should be performed in your extension (such as closing data base connections or other resource deallocations). You can register such a function with gawk using the following function.
void awk_atexit(void (*funcp)(void *data, int exit_status),
dataparameter will be the original value of
exit_statusparameter is the exit status value that gawk intends to pass to the
Exit callback functions are called in Last-In-First-Out (LIFO) order—that is, in the reverse order in which they are registered with gawk.