atexit
atexit — evaluates code before exiting a program.
atexit (code)
codeCode to be evaluated.
The result of evaluating code.
This function gives a program an opportunity to evaluate specified code
before it exits. The code should be protected from
evaluation using the quote operator #.
Running this program...
#!/usr/cogent/bin/gamma
// Program name: exiting.g
// Demonstrates the atexit() function.
atexit(#princ("Exiting now.\n"));
princ("Started running...\n");
princ("Still running.\n");
exit_program(7);
princ("You missed this part.\n");
...gives these results:
[sh]$exiting.gStarted running... Still running. Exiting now.[sh]$