The exit function

Name

exit -- 

Synopsis

#include <stdlib.h>

void exit (int status);

Description

The exit function causes normal program termination to occur. If more than one call to the exit function is executed by a program, the behavior is undefined.

First, all functions registered by the atexit function are called, in the reverse order of their registration.

Next, all open streams with unwritten buffered data are flushed, all open streams are closed, and all files created by the tmpfile function are removed.

Finally, control is returned to the host environment. If the value of status is zero or EXIT_SUCCESS, an implementation-defined form of the status successful termination is returned. If the value of status is EXIT_FAILURE, and implementation-defined form of the status unsuccessful termination is returned. Otherwise the status returned is implementation-defined.

Returns

The exit function cannot return to its caller.

Implementation Notes

The host environment consists of the file crt0, which initializes the stack then calls the main program. On return from the main program, the environment restarts and runs the main program again.
The XGC library does not support buffered streams or temporary files.