atexit (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.g Started running... Still running. Exiting now. [sh]$
Copyright © 1995-2012 by Cogent Real-Time Systems, Inc. All rights reserved.