The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group

 NAME

exit, _exit - terminate a process

 SYNOPSIS



#include <stdlib.h>

void exit(int status);

#include <unistd.h>

void _exit(int status);

 DESCRIPTION

The exit() function first calls all functions registered by atexit(), in the reverse order of their registration. Each function is called as many times as it was registered.

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 effects are undefined.

The exit() function then flushes all output streams, closes all open streams, and removes all files created by tmpfile(). Finally, control is returned to the host environment as described below. The values of status can be EXIT_SUCCESS or EXIT_FAILURE, as described in <stdlib.h>, or any implementation-dependent value, although note that only the range 0 through 255 will be available to a waiting parent process.

The _exit() and exit() functions terminate the calling process with the following consequences:

 RETURN VALUE

These functions do not return.

 ERRORS

No errors are defined.

 EXAMPLES

None.

 APPLICATION USAGE

Normally applications should use exit() rather than _exit().

 FUTURE DIRECTIONS

None.

 SEE ALSO

atexit(), close(), fclose(), semop(), shmget(), sigaction(), wait(), wait3(), waitid(), waitpid(), <stdlib.h>, <unistd.h>.

DERIVATION

Derived from Issue 1 of the SVID.

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]