EXIT - terminate program execution.

(ANSI Standard)


#include <stdlib.h>
exit( 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.


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 passed back in register X0 on the OCLIMB operation.

For compatibility with other versions of C, you should only count on the lowest eight bits of "status" being returned to the caller.

Copyright © 1996, Thinkage Ltd.