gawk: Exit Callback Functions

1 
1 16.4.5.2 Registering An Exit Callback Function
1 ..............................................
1 
1 An "exit callback" function is a function that 'gawk' calls before it
1 exits.  Such functions are useful if you have general "cleanup" tasks
1 that should be performed in your extension (such as closing database
1 connections or other resource deallocations).  You can register such a
1 function with 'gawk' using the following function:
1 
1 'void awk_atexit(void (*funcp)(void *data, int exit_status),'
1 '                void *arg0);'
1      The parameters are:
1 
1      'funcp'
1           A pointer to the function to be called before 'gawk' exits.
1           The 'data' parameter will be the original value of 'arg0'.
1           The 'exit_status' parameter is the exit status value that
1           'gawk' intends to pass to the 'exit()' system call.
1 
1      'arg0'
1           A pointer to private data that 'gawk' saves in order to pass
1           to the function pointed to by 'funcp'.
1 
1    Exit callback functions are called in last-in, first-out (LIFO)
1 order--that is, in the reverse order in which they are registered with
1 'gawk'.
1