void _Exit(int status);
void _exit(int status);
IEEE Std 1003.1-2017
_exit() functions terminate the calling process.
The value of status may be
EXIT_FAILURE, or any other value, though only the least significant 8 bits (that is,
status & 0xff) are available from
waitpid(); the full value is available from
waitid() and in the
siginfo_t passed to a signal handler for
The functions do not call functions registered with
atexit() nor any registered signal handlers. Open streams are not flushed, but opened file descriptors are closed. Finally, the calling process is terminated with the consequences described below.
Consequences of Process Termination
All of the file descriptors, directory streams, conversion descriptors, and message catalog descriptors open in the calling process are closed.
If the parent process of the calling process has set the action for the
SIGCHLD signal to
The process' status information, if any, is discarded.
The lifetime of the calling process ends immediately and a
SIGCHLDsignal is sent to the parent process.
If a thread in the parent process of the calling process is blocked in
waitid(), and the parent process has no remaining child processes in the set of waited-for children, the
waitpid()function fails and sets errno to
Status information is generated.
The calling process is transformed into a zombie process. Its status information is made available to the parent process until the process' lifetime ends.
The process' lifetime ends once its parent obtains the process' status information via a currently-blocked or future call to
If one or more threads in the parent process of the calling process is blocked in a call to
waitpid()awaiting termination of the process, one (or, if any are calling
WNOWAIT, possibly more) of these threads obtains the process' status information as specified in Status Information and becomes unblocked.
SIGCHLDis sent to the parent process.
Termination of a process does not directly terminate its children. The sending of a
SIGHUP signal as described below indirectly terminates children in some circumstances.
If the process is a controlling process, the
SIGHUP signal is sent to each process in the foreground process group of the controlling terminal belonging to the calling process.
If the process is a controlling process, the controlling terminal associated with the session is disassociated from the session, allowing it to be acquired by a new controlling process.
The parent process ID of all of the existing child processes and zombie processes of the calling process are set to the process ID of an
init system process. That is, these processes are inherited by a
Memory mappings that were created in the process are unmapped before the process is destroyed.
Threads terminated by a call to
_Exit() do not invoke their cancellation cleanup handlers or per-thread data destructors.
If the calling process is a trace controller process, any trace streams that were created by the calling process are shut down as described by the
posix_trace_shutdown() function, and mapping of trace event names to trace event type identifiers of any process built for these trace streams may be deallocated.
The functions can never return.
No errors are defined.