Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

_exit(2) [mojave man page]

EXIT(2) 						      BSD System Calls Manual							   EXIT(2)

NAME
_exit -- terminate the calling process SYNOPSIS
#include <unistd.h> void _exit(int status); DESCRIPTION
The _exit() function terminates a process, with the following consequences: o All of the descriptors that were open 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. o If the parent process of the calling process has an outstanding wait call or catches the SIGCHLD signal, it is notified of the calling process's termination; the status is set as defined by wait(2). o The parent process-ID of all of the calling process's existing child processes are set to 1; the initialization process (see the DEFINI- TIONS section of intro(2)) inherits each of these processes. o 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 signal and the SIGCONT signal are sent to all members of the newly-orphaned process group. o If the process is a controlling process (see intro(2)), the SIGHUP signal is sent to the foreground process group of the controlling ter- minal. 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., before calling _exit(). RETURN VALUE
_exit() can never return. SEE ALSO
fork(2), sigaction(2), wait(2), exit(3) STANDARDS
The _exit function is defined by IEEE Std 1003.1-1988 (``POSIX.1''). 4th Berkeley Distribution June 4, 1993 4th Berkeley Distribution

Check Out this Related Man Page

EXIT(3) 						     Linux Programmer's Manual							   EXIT(3)

NAME
exit - cause normal program termination SYNOPSIS
#include <stdlib.h> void exit(int status); DESCRIPTION
The exit() function causes normal program termination and the the value of status & 0377 is returned to the parent (see wait(2)). All functions registered with atexit() and on_exit() are called in the reverse order of their registration, and all open streams are flushed and closed. Files created by tmpfile() are removed. The C standard specifies two defines EXIT_SUCCESS and EXIT_FAILURE that may be passed to exit() to indicate successful or unsuccessful ter- mination, respectively. RETURN VALUE
The exit() function does not return. CONFORMING TO
SVID 3, POSIX, BSD 4.3, ISO 9899 (``ANSI C'') NOTES
During the exit processing, it is possible to register additional functions with atexit() and on_exit(). Always the last-registered func- tion is removed from the chain of registered functions, and invoked. It is undefined what happens if during this processing either exit() or longjmp() is called. The use of EXIT_SUCCESS and EXIT_FAILURE is slightly more portable (to non-Unix environments) than that of 0 and some nonzero value like 1 or -1. In particular, VMS uses a different convention. BSD has attempted to standardize exit codes - see the file <sysexits.h>. After exit(), the exit status must be transmitted to the parent process. There are three cases. If the parent has set SA_NOCLDWAIT, or has set the SIGCHLD handler to SIG_IGN, the status is discarded. If the parent was waiting on the child it is notified of the exit status. In both cases the exiting process dies immediately. If the parent has not indicated that it is not interested in the exit status, but is not waiting, the exiting process turns into a "zombie" process (which is nothing but a container for the single byte representing the exit sta- tus) so that the parent can learn the exit status when it later calls one of the wait() functions. If the implementation supports the SIGCHLD signal, this signal is sent to the parent. If the parent has set SA_NOCLDWAIT, it is undefined whether a SIGCHLD signal is sent. If the process is a session leader and its controlling terminal the controlling terminal of the session, then each process in the fore- ground process group of this controlling terminal is sent a SIGHUP signal, and the terminal is disassociated from this session, allowing it to be acquired by a new controlling process. If the exit of the process causes a process group to become orphaned, and if any member of the newly-orphaned process group is stopped, then a SIGHUP signal followed by a SIGCONT signal will be sent to each process in this process group. SEE ALSO
_exit(2), wait(2), atexit(3), on_exit(3), tmpfile(3) 2001-11-17 EXIT(3)
Man Page