]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/_exit.2
man*/: srcfix (Use .P instead of .PP or .LP)
[thirdparty/man-pages.git] / man2 / _exit.2
CommitLineData
fea681da 1.\" This manpage is Copyright (C) 1992 Drew Eckhardt;
ac56b6a8 2.\" and Copyright (C) 1993 Michael Haardt, Ian Jackson.
fea681da 3.\"
5fbde956 4.\" SPDX-License-Identifier: Linux-man-pages-copyleft
fea681da
MK
5.\"
6.\" Modified Wed Jul 21 23:02:38 1993 by Rik Faith <faith@cs.unc.edu>
7.\" Modified 2001-11-17, aeb
8.\"
4c1c5274 9.TH _exit 2 (date) "Linux man-pages (unreleased)"
fea681da 10.SH NAME
a1ffe9f5 11_exit, _Exit \- terminate the calling process
edf2e4a8
AC
12.SH LIBRARY
13Standard C library
8fc3b2cf 14.RI ( libc ", " \-lc )
fea681da 15.SH SYNOPSIS
c7db92b9 16.nf
fea681da 17.B #include <unistd.h>
c6d039a3 18.P
9b2f5804 19.BI "[[noreturn]] void _exit(int " status );
c6d039a3 20.P
fea681da 21.B #include <stdlib.h>
c6d039a3 22.P
9b2f5804 23.BI "[[noreturn]] void _Exit(int " status );
c7db92b9 24.fi
c6d039a3 25.P
d39ad78f 26.RS -4
cc4615cc
MK
27Feature Test Macro Requirements for glibc (see
28.BR feature_test_macros (7)):
d39ad78f 29.RE
c6d039a3 30.P
cc4615cc 31.BR _Exit ():
9d2adbae 32.nf
5c10d2c5 33 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
9d2adbae 34.fi
fea681da 35.SH DESCRIPTION
63aa9df0 36.BR _exit ()
c13182ef 37terminates the calling process "immediately".
55873ed6 38Any open file descriptors belonging to the process are closed.
99ed723a 39Any children of the process are inherited by
a88f0e06 40.BR init (1)
99ed723a
MK
41(or by the nearest "subreaper" process as defined through the use of the
42.BR prctl (2)
43.B PR_SET_CHILD_SUBREAPER
44operation).
55873ed6 45The process's parent is sent a
fea681da
MK
46.B SIGCHLD
47signal.
c6d039a3 48.P
fea681da 49The value
f3491e47 50.I "status & 0xFF"
fea681da 51is returned to the parent process as the process's exit status, and
07f462e9 52can be collected by the parent using one of the
0bfa087b 53.BR wait (2)
fea681da 54family of calls.
c6d039a3 55.P
fea681da 56The function
63aa9df0 57.BR _Exit ()
fea681da 58is equivalent to
63aa9df0 59.BR _exit ().
47297adb 60.SH RETURN VALUE
fea681da 61These functions do not return.
3113c7f3 62.SH STANDARDS
4131356c
AC
63.TP
64.BR _exit ()
65POSIX.1-2008.
66.TP
67.BR _Exit ()
68C11, POSIX.1-2008.
69.SH HISTORY
70POSIX.1-2001, SVr4, 4.3BSD.
c6d039a3 71.P
60a90ecd
MK
72.BR _Exit ()
73was introduced by C99.
fea681da
MK
74.SH NOTES
75For a discussion on the effects of an exit, the transmission of
078a7d6e 76exit status, zombie processes, signals sent, and so on, see
fea681da 77.BR exit (3).
c6d039a3 78.P
fea681da 79The function
63aa9df0 80.BR _exit ()
60a90ecd
MK
81is like
82.BR exit (3),
83but does not call any
7b57506d 84functions registered with
0bfa087b 85.BR atexit (3)
c13182ef 86or
0bfa087b 87.BR on_exit (3).
29c4533c
MK
88Open
89.BR stdio (3)
90streams are not flushed.
fea681da 91On the other hand,
63aa9df0 92.BR _exit ()
fea681da 93does close open file descriptors, and this may cause an unknown delay,
c13182ef
MK
94waiting for pending output to finish.
95If the delay is undesired,
988db661 96it may be useful to call functions like
0bfa087b 97.BR tcflush (3)
60a90ecd
MK
98before calling
99.BR _exit ().
d9bfdb9c
MK
100Whether any pending I/O is canceled, and which pending I/O may be
101canceled upon
60a90ecd
MK
102.BR _exit (),
103is implementation-dependent.
0722a578 104.SS C library/kernel differences
d99b5be0
MK
105The text above in DESCRIPTION describes the traditional effect of
106.BR _exit (),
107which is to terminate a process,
724433bb 108and these are the semantics specified by POSIX.1 and implemented
d99b5be0
MK
109by the C library wrapper function.
110On modern systems, this means termination of all threads in the process.
c6d039a3 111.P
d99b5be0 112By contrast with the C library wrapper function, the raw Linux
cd356fa1 113.BR _exit ()
737a840d
MK
114system call terminates only the calling thread, and actions such as
115reparenting child processes or sending
116.B SIGCHLD
117to the parent process are performed only if this is
118the last thread in the thread group.
119.\" _exit() is used by pthread_exit() to terminate the calling thread
c6d039a3 120.P
b324e17d 121Up to glibc 2.3, the
d99b5be0
MK
122.BR _exit ()
123wrapper function invoked the kernel system call of the same name.
124Since glibc 2.3, the wrapper function invokes
125.BR exit_group (2),
126in order to terminate all of the threads in a process.
47297adb 127.SH SEE ALSO
fea681da 128.BR execve (2),
f02720dd 129.BR exit_group (2),
fea681da
MK
130.BR fork (2),
131.BR kill (2),
132.BR wait (2),
133.BR wait4 (2),
134.BR waitpid (2),
7b57506d 135.BR atexit (3),
fea681da 136.BR exit (3),
7b57506d 137.BR on_exit (3),
fea681da 138.BR termios (3)