OSDN Git Service

cd075bccb8b4950c9855fdc3120b8605d3a32165
[linuxjm/LDP_man-pages.git] / original / man2 / _exit.2
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" This manpage is Copyright (C) 1992 Drew Eckhardt;
4 .\"                               1993 Michael Haardt, Ian Jackson.
5 .\"
6 .\" Permission is granted to make and distribute verbatim copies of this
7 .\" manual provided the copyright notice and this permission notice are
8 .\" preserved on all copies.
9 .\"
10 .\" Permission is granted to copy and distribute modified versions of this
11 .\" manual under the conditions for verbatim copying, provided that the
12 .\" entire resulting derived work is distributed under the terms of a
13 .\" permission notice identical to this one.
14 .\"
15 .\" Since the Linux kernel and libraries are constantly changing, this
16 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
17 .\" responsibility for errors or omissions, or for damages resulting from
18 .\" the use of the information contained herein.  The author(s) may not
19 .\" have taken the same level of care in the production of this manual,
20 .\" which is licensed free of charge, as they might when working
21 .\" professionally.
22 .\"
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
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 2010-09-20 "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 _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE ||
50 _POSIX_C_SOURCE\ >=\ 200112L;
51 .br
52 or
53 .I cc\ -std=c99
54 .ad
55 .SH DESCRIPTION
56 The function
57 .BR _exit ()
58 terminates the calling process "immediately".
59 Any open file descriptors
60 belonging to the process are closed; any children of the process are
61 inherited by process 1,
62 .IR init ,
63 and the process's parent is sent a
64 .B SIGCHLD
65 signal.
66 .LP
67 The value
68 .I status
69 is returned to the parent process as the process's exit status, and
70 can be collected using one of the
71 .BR wait (2)
72 family of calls.
73 .LP
74 The function
75 .BR _Exit ()
76 is equivalent to
77 .BR _exit ().
78 .SH "RETURN VALUE"
79 These functions do not return.
80 .SH "CONFORMING TO"
81 SVr4, POSIX.1-2001, 4.3BSD.
82 The function
83 .BR _Exit ()
84 was introduced by C99.
85 .SH NOTES
86 For a discussion on the effects of an exit, the transmission of
87 exit status, zombie processes, signals sent, etc., see
88 .BR exit (3).
89 .LP
90 The function
91 .BR _exit ()
92 is like
93 .BR exit (3),
94 but does not call any
95 functions registered with
96 .BR atexit (3)
97 or
98 .BR on_exit (3).
99 Whether it flushes
100 standard I/O buffers and removes temporary files created with
101 .BR tmpfile (3)
102 is implementation-dependent.
103 On the other hand,
104 .BR _exit ()
105 does close open file descriptors, and this may cause an unknown delay,
106 waiting for pending output to finish.
107 If the delay is undesired,
108 it may be useful to call functions like
109 .BR tcflush (3)
110 before calling
111 .BR _exit ().
112 Whether any pending I/O is canceled, and which pending I/O may be
113 canceled upon
114 .BR _exit (),
115 is implementation-dependent.
116
117 In glibc up to version 2.3, the
118 .BR _exit ()
119 wrapper function invoked the kernel system call of the same name.
120 Since glibc 2.3, the wrapper function invokes
121 .BR exit_group (2),
122 in order to terminate all of the threads in a process.
123 .SH "SEE ALSO"
124 .BR execve (2),
125 .BR exit_group (2),
126 .BR fork (2),
127 .BR kill (2),
128 .BR wait (2),
129 .BR wait4 (2),
130 .BR waitpid (2),
131 .BR atexit (3),
132 .BR exit (3),
133 .BR on_exit (3),
134 .BR termios (3)