LinuxReviws.org --get your your Linux knowledge
> Linux Reviews > Manual Pages (man) >

exit


  1. exit.1.man
  2. exit.2.man
  3. exit.3.man
  4. exit.9.man


1. exit.1.man

Invalid Manpage

Invalid Manpage

The requested file (stdin) is not a valid (unformatted) man page.

2. exit.2.man

Invalid Manpage

Invalid Manpage

The requested file (stdin) is not a valid (unformatted) man page.

3. exit.3.man

Manpage of EXIT

EXIT

Section: Linux Programmer's Manual (3)
Updated: 2009-09-20
Index Return to Main Contents
 

NAME

exit - cause normal process termination  

SYNOPSIS

#include <stdlib.h>

void exit(int status);
 

DESCRIPTION

The 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.

All open stdio(3) streams are flushed and closed. Files created by tmpfile(3) are removed.

The C standard specifies two constants, EXIT_SUCCESS and EXIT_FAILURE, that may be passed to exit() to indicate successful or unsuccessful termination, respectively.  

RETURN VALUE

The exit() function does not return.  

CONFORMING TO

SVr4, 4.3BSD, POSIX.1-2001, C89, C99.  

NOTES

It is undefined what happens if one of the functions registered using atexit(3) and on_exit(3) calls either exit() or longjmp(3).

The use of EXIT_SUCCESS and EXIT_FAILURE is 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 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 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 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 is the controlling terminal of the session, then each process in the foreground 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 setpgid(2) for an explanation of orphaned process groups.  

SEE ALSO

_exit(2), setpgid(2), wait(2), atexit(3), on_exit(3), tmpfile(3)  

COLOPHON

This page is part of release 3.32 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/.


 

Index

NAME
SYNOPSIS
DESCRIPTION
RETURN VALUE
CONFORMING TO
NOTES
SEE ALSO
COLOPHON

This document was created by man2html using the manual pages.
Time: 17:30:52 GMT, October 23, 2013

4. exit.9.man

Manpage of exit

exit

Section: Tcl Built-In Commands (n)
Updated:
Index Return to Main Contents



 

NAME

exit - End the application  

SYNOPSIS

exit ?returnCode?



 

DESCRIPTION

Terminate the process, returning returnCode to the system as the exit status. If returnCode is not specified then it defaults to 0.  

EXAMPLE

Since non-zero exit codes are usually interpreted as error cases by the calling process, the exit command is an important part of signaling that something fatal has gone wrong. This code fragment is useful in scripts to act as a general problem trap:

proc main {} {
    # ... put the real main code in here ...
}

if {[catch {main} msg options]} {
    puts stderr "unexpected script error: $msg"
    if {[info exist env(DEBUG)]} {
        puts stderr "---- BEGIN TRACE ----"
        puts stderr [dict get $options -errorinfo]
        puts stderr "---- END TRACE ----"
    }

    # Reserve code 1 for "expected" error exits...
    exit 2
}

 

SEE ALSO

exec(n)

 

KEYWORDS

exit, process


 

Index

NAME
SYNOPSIS
DESCRIPTION
EXAMPLE
SEE ALSO
KEYWORDS

This document was created by man2html using the manual pages.
Time: 17:30:52 GMT, October 23, 2013

ENGLISH - ENGLISH - cs - da - ENGLISH - ENGLISH - ENGLISH - ENGLISH - ja - nl - pl - ro - ENGLISH - zh_CN

Meet new people