_EXIT(2)

NAME
_exit, _Exit - terminate the calling process

SYNOPSIS
#include <unistd.h>
void
_exit(int status);
#include <stdlib.h>
void
_Exit(int status);

DESCRIPTION
The _exit() and _Exit() functions terminate a process with the following consequences:

•   All threads in the process are terminated.

•   All open file descriptors in the calling process are closed. This may entail delays; for example, waiting for output to drain. A process in this state may not be killed, as it is already dying.

•   If the parent process of the calling process has an outstanding wait(2) call or catches the SIGCHLD signal, it is notified of the calling process's termination and status is set as defined by wait(2). (Note that typically only the lower 8 bits of status are passed on to the parent, thus negative values have less meaning.)

•   The parent process ID of all of the calling process's existing child processes are set to 1; the initialization process (see the DEFINITIONS section of intro(2)) inherits each of these processes.

•   If the termination of the process causes any process group to become orphaned (usually because the parents of all members of the group have now exited; see Orphaned Process Group in intro(2)), and if any member of the orphaned group is stopped, the SIGHUP and SIGCONT signals are sent to all members of the newly orphaned process group.

•   If the process is a controlling process (see intro(2)), the SIGHUP signal is sent to the foreground process group of the controlling terminal, and all current access to the controlling terminal is revoked.

Most C programs call the library routine exit(3), which flushes buffers, closes streams, unlinks temporary files, etc., and then calls _exit().

RETURN VALUES
_exit() and _Exit() can never return.

SEE ALSO
fork(2), intro(2), sigaction(2), wait(2), exit(3), sysexits(3)

STANDARDS
The _exit() function conforms to p1003.1-2008. The _Exit() function conforms to isoC-99.

HISTORY
An exit() system call first appeared in AT&T UNIX. It accepts the status argument since AT&T UNIX. An _exit() variant first appeared in AT&T UNIX. The _Exit() function appeared in OpenBSD 3.6.