Implementation status: implemented
void exit(int status);
exit() function terminates a process.
status - a value returned to the system; the most popular values are
There can any other value be returned, though only the least significant
8 bits (that is,
status & 0377) are available from
waitpid(); the full value is available from
waitid() and in the
siginfo_t passed to a signal handler for
exit() function first calls all functions registered by
atexit(), in the reverse order of their registration, except that a function is called after any previously registered functions that had already been called at the time it was registered. Each function is called as many times as it was registered. If, during the call to any such function, a call to the
longjmp() function is made that would terminate the call to the registered function, the behavior is undefined.
If a function registered by a call to
atexit() fails to return, the remaining registered functions are not called and the rest of the
exit() processing is not completed. If
exit() is called more than once, the behavior is undefined.
exit() function flushes all open streams with unwritten buffered data and close all open streams. Finally, the process is terminated.
exit() function does not return.
No errors are defined.