EXIT - terminate program execution.

(ANSI Standard)

Usage:

#include <stdlib.h>
exit( status );

Where:

int status;
is a status that will be returned to whatever called the current program. <stdlib.h> defines two manifests that may be used as the argument of "exit". EXIT_SUCCESS indicates normal program termination and EXIT_FAILURE indicates program failure.

Description:

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.

See Also:

expl b lib exit

Copyright © 1996, Thinkage Ltd.