Manpage of EXIT
EXITSection: Linux Programmer's Manual (3)
NAMEexit - cause normal process termination
#include <stdlib.h>void exit(int status);
DESCRIPTIONThe exit() function causes normal process termination and the value of status & 0377 is returned to the parent (see wait(2)).
All functions registered with atexit(3) and on_exit(3) are called, in the reverse order of their registration. (It is possible for one of these functions to use atexit(3) or on_exit(3) to register an additional function to be executed during exit processing; the new registration is added to the front of the list of functions that remain to be called.) If one of these functions does not return (e.g., it calls _exit(2), or kills itself with a signal), then none of the remaining functions is called, and further exit processing (in particular, flushing of stdio(3) streams) is abandoned. If a function has been registered multiple times using atexit(3) or on_exit(3), then it is called as many times as it was registered.
RETURN VALUEThe exit() function does not return.
ATTRIBUTESFor an explanation of the terms used in this section, see attributes(7).
|exit()||Thread safety||MT-Unsafe race:exit|
CONFORMING TOPOSIX.1-2001, POSIX.1-2008, C89, C99, SVr4, 4.3BSD.
It is undefined what happens if one of the functions registered using atexit(3) and on_exit(3) calls either exit() or longjmp(3). Note that a call to execve(2) removes registrations created using atexit(3) and on_exit(3).
The use of EXIT_SUCCESSand EXIT_FAILUREis slightly more portable (to non-UNIX environments) than the use 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 SIGCHLDhandler 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 status) so that the parent can learn the exit status when it later calls one of the wait(2) functions.
If the implementation supports the SIGCHLDsignal, this signal is sent to the parent. If the parent has set SA_NOCLDWAIT, it is undefined whether a SIGCHLDsignal is sent.
If the process is a session leader and its controlling terminal is the controlling terminal of the session, then each process in the foreground process group of this controlling terminal is sent a SIGHUPsignal, 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 SIGHUPsignal followed by a SIGCONTsignal will be sent to each process in this process group. See setpgid(2) for an explanation of orphaned process groups.
SEE ALSO_exit(2), setpgid(2), wait(2), atexit(3), on_exit(3), tmpfile(3)
This document was created by man2html, using the manual pages.
Time: 16:30:26 GMT, October 09, 2016 Click Here!