#include <stdlib.h> exit( status );
The "exit" function terminates program execution and returns the status value to the system.
The function begins its work by calling all the clean-up functions specified by "atexit" routines, in the reverse order that the functions were specified (so that the most recently specified clean-up function is executed first). These clean-up functions are executed in an environment that makes it look as if "main" has just returned. This means that automatic storage duration objects created by the program may not be accessed.
Next, "exit" flushes all I/O buffers and closes any streams that are currently open. Files created with the "tmpfile" function are removed.
Lastly, control is returned to the system. The system receives the status value indicating the success or failure of the program. The status is encoded in the program switch words in the same way as the UW Tools "exit" function; see "expl b lib exit" for details. In TSS, EXIT_FAILURE also issues a DRL T.ERR indicating an error.
For compatibility with other versions of C, you should only count on the lowest eight bits of "status" being returned to the caller.
expl b lib exit
Copyright © 1996, Thinkage Ltd.