]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/_exit.2
sock_diag.7: Tweaks to Dmitry Levin's page
[thirdparty/man-pages.git] / man2 / _exit.2
1 .\" This manpage is Copyright (C) 1992 Drew Eckhardt;
2 .\" and Copyright (C) 1993 Michael Haardt, Ian Jackson.
3 .\"
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein. The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" %%%LICENSE_END
25 .\"
26 .\" Modified Wed Jul 21 23:02:38 1993 by Rik Faith <faith@cs.unc.edu>
27 .\" Modified 2001-11-17, aeb
28 .\"
29 .TH _EXIT 2 2016-03-15 "Linux" "Linux Programmer's Manual"
30 .SH NAME
31 _exit, _Exit \- terminate the calling process
32 .SH SYNOPSIS
33 .B #include <unistd.h>
34 .sp
35 .BI "void _exit(int " status );
36 .sp
37 .B #include <stdlib.h>
38 .sp
39 .BI "void _Exit(int " status );
40 .sp
41 .in -4n
42 Feature Test Macro Requirements for glibc (see
43 .BR feature_test_macros (7)):
44 .in
45 .sp
46 .ad l
47 .BR _Exit ():
48 .RS 4
49 _ISOC99_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L
50 .RE
51 .ad
52 .SH DESCRIPTION
53 The function
54 .BR _exit ()
55 terminates the calling process "immediately".
56 Any open file descriptors
57 belonging to the process are closed; any children of the process are
58 inherited by process 1,
59 .IR init ,
60 and the process's parent is sent a
61 .B SIGCHLD
62 signal.
63 .LP
64 The value
65 .I status
66 is returned to the parent process as the process's exit status, and
67 can be collected using one of the
68 .BR wait (2)
69 family of calls.
70 .LP
71 The function
72 .BR _Exit ()
73 is equivalent to
74 .BR _exit ().
75 .SH RETURN VALUE
76 These functions do not return.
77 .SH CONFORMING TO
78 POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD.
79 The function
80 .BR _Exit ()
81 was introduced by C99.
82 .SH NOTES
83 For a discussion on the effects of an exit, the transmission of
84 exit status, zombie processes, signals sent, and so on, see
85 .BR exit (3).
86 .LP
87 The function
88 .BR _exit ()
89 is like
90 .BR exit (3),
91 but does not call any
92 functions registered with
93 .BR atexit (3)
94 or
95 .BR on_exit (3).
96 Open
97 .BR stdio (3)
98 streams are not flushed.
99 On the other hand,
100 .BR _exit ()
101 does close open file descriptors, and this may cause an unknown delay,
102 waiting for pending output to finish.
103 If the delay is undesired,
104 it may be useful to call functions like
105 .BR tcflush (3)
106 before calling
107 .BR _exit ().
108 Whether any pending I/O is canceled, and which pending I/O may be
109 canceled upon
110 .BR _exit (),
111 is implementation-dependent.
112 .SS C library/kernel differences
113 In glibc up to version 2.3, the
114 .BR _exit ()
115 wrapper function invoked the kernel system call of the same name.
116 Since glibc 2.3, the wrapper function invokes
117 .BR exit_group (2),
118 in order to terminate all of the threads in a process.
119 .SH SEE ALSO
120 .BR execve (2),
121 .BR exit_group (2),
122 .BR fork (2),
123 .BR kill (2),
124 .BR wait (2),
125 .BR wait4 (2),
126 .BR waitpid (2),
127 .BR atexit (3),
128 .BR exit (3),
129 .BR on_exit (3),
130 .BR termios (3)