OSDN Git Service

(split) LDP v3.30, v3.31 の定型的な変更内容を反映。
[linuxjm/LDP_man-pages.git] / draft / man3 / exit.3
1 .\" Copyright (C) 2001 Andries Brouwer <aeb@cwi.nl>.
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.  The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" Japanese Version Copyright (c) 1997 HORIMOTO Masafumi
24 .\"         all rights reserved.
25 .\" Translated 1997-09-10, HORIMOTO Masafumi
26 .\" Updated & Modified 2001-10-27, Yuichi SATO <ysato@h4.dion.ne.jp>
27 .\" Updated & Modified 2001-12-09, Yuichi SATO
28 .\" Updated & Modified 2005-09-06, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
29 .\" Updated 2007-06-18, Akihiro MOTOKI, LDP v2.57
30 .\"
31 .TH EXIT 3  2009-09-20 "Linux" "Linux Programmer's Manual"
32 .\"O .SH NAME
33 .SH Ì¾Á°
34 .\"O exit \- cause normal process termination
35 exit \- ¥×¥í¥»¥¹¤ÎÀµ¾ï½ªÎ»
36 .\"O .SH SYNOPSIS
37 .SH ½ñ¼°
38 .nf
39 .B #include <stdlib.h>
40 .sp
41 .BI "void exit(int " status );
42 .fi
43 .\"O .SH DESCRIPTION
44 .SH ÀâÌÀ
45 .\"O The
46 .\"O .BR exit ()
47 .\"O function causes normal process termination and the
48 .\"O value of \fIstatus & 0377\fP is returned to the parent
49 .\"O (see
50 .\"O .BR wait (2)).
51 .BR exit ()
52 ´Ø¿ô¤Ï¡¢¥×¥í¥»¥¹¤òÀµ¾ï¤Ë½ªÎ»¤µ¤»¡¢
53 \fIstatus & 0377\fP ¤È¤¤¤¦Ãͤò¿Æ¥×¥í¥»¥¹¤ØÊÖ¤¹
54 .RB ( wait (2)
55 ¤ò»²¾È)¡£
56 .LP
57 .\"O All functions registered with
58 .\"O .BR atexit (3)
59 .\"O and
60 .\"O .BR on_exit (3)
61 .\"O are called, in the reverse order of their registration.
62 .\"O (It is possible for one of these functions to use
63 .\"O .BR atexit (3)
64 .\"O or
65 .\"O .BR on_exit (3)
66 .\"O to register an additional
67 .\"O function to be executed during exit processing;
68 .\"O the new registration is added to the front of the list of functions
69 .\"O that remain to be called.)
70 .BR atexit (3)
71 ¤ä
72 .BR on_exit (3)
73 ¤Ë¤è¤Ã¤Æ
74 ÅÐÏ¿¤µ¤ì¤¿Á´¤Æ¤Î´Ø¿ô¤Ï¡¢¤½¤ì¤é¤¬ÅÐÏ¿¤µ¤ì¤¿½çÈ֤ȵսç¤Ë¥³¡¼¥ë¤µ¤ì¤ë¡£
75 (ÅÐÏ¿¤µ¤ì¤¿´Ø¿ô¤ÎÃæ¤Ç
76 .BR atexit (3)
77 or
78 .BR on_exit (3)
79 ¤ò»È¤Ã¤Æ
80 exit ½èÍýÃæ¤Ë¼Â¹Ô¤µ¤ì¤ëÄɲäδؿô¤òÅÐÏ¿¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë;
81 ¿·µ¬¤ËÅÐÏ¿¤µ¤ì¤¿´Ø¿ô¤Ï¡¢¤³¤Î¸å¤Ç¼Â¹Ô¤µ¤ì¤ë´Ø¿ô¥ê¥¹¥È¤ÎÀèƬ¤Ë
82 Äɲ䵤ì¤ë¡£)
83 .\"O If one of these functions does not return
84 .\"O (e.g., it calls
85 .\"O .BR _exit (2),
86 .\"O or kills itself with a signal),
87 .\"O then none of the remaining functions is called,
88 .\"O and further exit processing (in particular, flushing of
89 .\"O .BR stdio (3)
90 .\"O streams) is abandoned.
91 .\"O If a function has been registered multiple times using
92 .\"O .BR atexit (3)
93 .\"O or
94 .\"O .BR on_exit (3),
95 .\"O then it is called as many times as it was registered.
96 ¤³¤ì¤é¤Î´Ø¿ô¤Î°ì¤Ä¤¬ÊÖ¤é¤Ê¤«¤Ã¤¿¾ì¹ç
97 (Î㤨¤Ð¡¢¤½¤Î´Ø¿ô¤¬
98 .BR _exit (2)
99 ¤ò¸Æ¤Ó½Ð¤·¤¿¤ê¡¢¥·¥°¥Ê¥ë¤Ç¼«Ê¬¼«¿È¤ò kill ¤·¤¿¾ì¹ç)¡¢
100 »Ä¤ê¤Î´Ø¿ô¤Ï¤É¤ì¤â¸Æ¤Ó½Ð¤µ¤ì¤º¡¢¤½¤ì°Ê¹ß¤Î exit ½èÍý
101 (ÆäË
102 .BR stdio (3)
103 ¥¹¥È¥ê¡¼¥à¤Î¥Õ¥é¥Ã¥·¥å¤Ê¤É) ¤ÏÃæ»ß¤µ¤ì¤ë¡£
104 ¤¢¤ë´Ø¿ô¤¬
105 .BR atexit (3)
106 ¤ä
107 .BR on_exit (3)
108 ¤ò»È¤Ã¤ÆÊ£¿ô²óÅÐÏ¿¤µ¤ì¤Æ¤¤¤¿¾ì¹ç¡¢
109 ¤½¤Î´Ø¿ô¤ÏÅÐÏ¿¤µ¤ì¤¿¤Î¤ÈƱ¤¸²ó¿ô¤À¤±¸Æ¤Ó½Ð¤µ¤ì¤ë¡£
110 .LP
111 .\"O All open
112 .\"O .BR stdio (3)
113 .\"O streams are flushed and closed.
114 .\"O Files created by
115 .\"O .BR tmpfile (3)
116 .\"O are removed.
117 ¥ª¡¼¥×¥óÃæ¤Î
118 .BR stdio (3)
119 ¥¹¥È¥ê¡¼¥à¤ÏÁ´¤Æ¥Õ¥é¥Ã¥·¥å¤µ¤ì¤Æ¡¢¥¯¥í¡¼¥º¤µ¤ì¤ë¡£
120 .BR tmpfile (3)
121 ¤Ë¤è¤Ã¤ÆºîÀ®¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¤Ïºï½ü¤µ¤ì¤ë¡£
122 .LP
123 .\"O The C standard specifies two constants,
124 .\"O \fBEXIT_SUCCESS\fP and \fBEXIT_FAILURE\fP,
125 .\"O that may be passed to
126 .\"O .BR exit ()
127 .\"O to indicate successful or unsuccessful
128 .\"O termination, respectively.
129 C É¸½à¤Ç¤Ï
130 .B EXIT_SUCCESS
131 ¤È
132 .B EXIT_FAILURE
133 ¤È¤¤¤¦ 2¤Ä¤ÎÄê¿ô¤¬
134 ÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£¤½¤ì¤¾¤ìÀµ¾ï½ªÎ»¤È°Û¾ï½ªÎ»¤ò¼¨¤¹¤â¤Î¤Ç¡¢
135 .BR exit ()
136 ¤È¤·¤ÆÅϤ¹¤³¤È¤¬¤Ç¤­¤ë¡£
137 .\"O .SH "RETURN VALUE"
138 .SH ÊÖ¤êÃÍ
139 .\"O The
140 .\"O .BR exit ()
141 .\"O function does not return.
142 .BR exit ()
143 ´Ø¿ô¤ÏÊÖ¤é¤Ê¤¤¡£
144 .\"O .SH "CONFORMING TO"
145 .SH ½àµò
146 SVr4, 4.3BSD, POSIX.1-2001, C89, C99.
147 .\"O .SH NOTES
148 .SH Ãí°Õ
149 .LP
150 .\"O It is undefined what happens if one of the
151 .\"O functions registered using
152 .\"O .BR atexit (3)
153 .\"O and
154 .\"O .BR on_exit (3)
155 .\"O calls either
156 .\"O .BR exit ()
157 .\"O or
158 .\"O .BR longjmp (3).
159 .BR atexit (3)
160 ¤ä
161 .BR on_exit (3)
162 ¤ò»È¤Ã¤ÆÅÐÏ¿¤µ¤ì¤¿´Ø¿ô¤ÎÃæ¤Ç
163 .BR exit ()
164 ¤«
165 .BR longjmp (3)
166 ¤¬¸Æ¤Ó½Ð¤µ¤ì¤¿¾ì¹ç¡¢
167 ²¿¤¬µ¯¤³¤ë¤«¤Ï̤ÄêµÁ¤Ç¤¢¤ë¡£
168 .LP
169 .\"O The use of
170 .\"O .B EXIT_SUCCESS
171 .\"O and
172 .\"O .B EXIT_FAILURE
173 .\"O is slightly more portable
174 .\"O (to non-UNIX environments) than the use of 0 and some nonzero value
175 .\"O like 1 or \-1.
176 .\"O In particular, VMS uses a different convention.
177 .B EXIT_SUCCESS
178 ¤È
179 .B EXIT_FAILURE
180 ¤ò»È¤¦¤È¡¢0 ¤ä (1 ¤ä \-1 ¤È¤¤¤Ã¤¿) 0 °Ê³°¤ÎÃͤò»È¤¦¤Î¤ËÈæ¤Ù¤Æ
181 (UNIX °Ê³°¤Î´Ä¶­¤Ë) °Ü¿¢¤¹¤ë¤Î¤¬¤¤¤¯¤é¤«´Êñ¤Ë¤Ê¤ë¡£
182 ÆäˠVMS ¤ÏÊ̤ÎÊý¼°¤òÍѤ¤¤Æ¤¤¤ë¡£
183 .LP
184 .\"O BSD has attempted to standardize exit codes; see the file
185 .\"O .IR <sysexits.h> .
186 BSD ¤Ï½ªÎ»¥³¡¼¥É¤òɸ½à²½¤·¤è¤¦¤È¤·¤Æ¤¤¤ë;
187 .I <sysexits.h>
188 ¤ò»²¾È¤¹¤ë¤³¤È¡£
189 .LP
190 .\"O After
191 .\"O .BR exit (),
192 .\"O the exit status must be transmitted to the
193 .\"O parent process.
194 .\"O There are three cases.
195 .\"O If the parent has set
196 .\"O .BR SA_NOCLDWAIT ,
197 .\"O or has set the
198 .\"O .B SIGCHLD
199 .\"O handler to
200 .\"O .BR SIG_IGN ,
201 .\"O the status is discarded.
202 .\"O If the parent was waiting on the child
203 .\"O it is notified of the exit status.
204 .\"O In both cases the exiting
205 .\"O process dies immediately.
206 .\"O If the parent has not indicated that
207 .\"O it is not interested in the exit status, but is not waiting,
208 .\"O the exiting process turns into a "zombie" process
209 .\"O (which is nothing but a container for the single byte representing
210 .\"O the exit status) so that the parent can learn the exit status when
211 .\"O it later calls one of the
212 .\"O .BR wait (2)
213 .\"O functions.
214 .BR exit ()
215 ¤Î¸å¡¢¿Æ¥×¥í¥»¥¹¤Ë½ªÎ»¥¹¥Æ¡¼¥¿¥¹¤¬ÅϤµ¤ì¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
216 ½ªÎ»¥¹¥Æ¡¼¥¿¥¹¤ÎÅϤ·Êý¤Ë¤Ï 3 ¤Ä¤Î¾ì¹ç¤¬¤¢¤ë¡£
217 ¿Æ¥×¥í¥»¥¹¤¬
218 .B SA_NOCLDWAIT
219 ¤òÀßÄꤷ¤¿¾ì¹ç¡¢
220 ¤Þ¤¿¤Ï
221 .B SIGCHLD
222 ¥Ï¥ó¥É¥é¤ò
223 .B SIG_IGN
224 ¤ËÀßÄꤷ¤¿¾ì¹ç¡¢
225 ¥¹¥Æ¡¼¥¿¥¹¤ÏÇË´þ¤µ¤ì¤ë¡£
226 ¿Æ¥×¥í¥»¥¹¤¬»Ò¥×¥í¥»¥¹¤Î½ªÎ»¤òÂԤäƤ¤¤ë¾ì¹ç¡¢
227 ¿Æ¥×¥í¥»¥¹¤Ë½ªÎ»¥¹¥Æ¡¼¥¿¥¹¤¬ÅÁ¤¨¤é¤ì¤ë¡£
228 ¤É¤Á¤é¤Î¾ì¹ç¤Ç¤â exit ¤Î¥×¥í¥»¥¹¤Ïľ¤Á¤Ë½ªÎ»¤¹¤ë¡£
229 ¡Ö½ªÎ»¥¹¥Æ¡¼¥¿¥¹¤ò´ØÃΤ»¤º½ªÎ»¤âÂÔ¤¿¤Ê¤¤¡×
230 ¤È¤¤¤¦¤³¤È¤ò¿Æ¥×¥í¥»¥¹¤¬»Ø¼¨¤·¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢
231 exit ¥×¥í¥»¥¹¤Ï (½ªÎ»¥¹¥Æ¡¼¥¿¥¹¤òɽ¤¹ 1 ¥Ð¥¤¥È¤Î¤ß¤òÊÝ»ý¤¹¤ë)
232 ¡Ö¥¾¥ó¥Ó¡×¥×¥í¥»¥¹¤Ë¤Ê¤ë¡£
233 ¤³¤ì¤Ë¤è¤ê¡¢¸å¤«¤é
234 .BR wait (2)
235 ´Ø¿ô¤ò¸Æ¤Ó½Ð¤¹¤³¤È¤Ç¡¢
236 ¿Æ¥×¥í¥»¥¹¤Ï½ªÎ»¥¹¥Æ¡¼¥¿¥¹¤òÃΤ뤳¤È¤¬¤Ç¤­¤ë¡£
237 .LP
238 .\"O If the implementation supports the
239 .\"O .B SIGCHLD
240 .\"O signal, this signal
241 .\"O is sent to the parent.
242 .\"O If the parent has set
243 .\"O .BR SA_NOCLDWAIT ,
244 .\"O it is undefined whether a
245 .\"O .B SIGCHLD
246 .\"O signal is sent.
247 .B SIGCHLD
248 ¥·¥°¥Ê¥ë¤Î¥µ¥Ý¡¼¥È¤¬¼ÂÁõ¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢
249 ¤³¤Î¥·¥°¥Ê¥ë¤Ï¿Æ¥×¥í¥»¥¹¤ËÁ÷¤é¤ì¤ë¡£
250 ¿Æ¥×¥í¥»¥¹¤¬
251 .B SA_NOCLDWAIT
252 ¤òÀßÄꤷ¤¿¾ì¹ç¡¢
253 .B SIGCHLD
254 ¥·¥°¥Ê¥ë¤¬Á÷¤é¤ì¤ë¤«¤É¤¦¤«¤ÏÄêµÁ¤µ¤ì¤Æ¤¤¤Ê¤¤¡£
255 .LP
256 .\"O If the process is a session leader and its controlling terminal
257 .\"O is the controlling terminal of the session, then each process in
258 .\"O the foreground process group of this controlling terminal
259 .\"O is sent a
260 .\"O .B SIGHUP
261 .\"O signal, and the terminal is disassociated
262 .\"O from this session, allowing it to be acquired by a new controlling
263 .\"O process.
264 ¤½¤Î¥×¥í¥»¥¹¤¬¥»¥Ã¥·¥ç¥ó¤Î¥ê¡¼¥À¡¼¤Ç¡¢
265 ¤½¤Î¥×¥í¥»¥¹¤ÎÀ©¸æüËö¤¬¤½¤Î¥»¥Ã¥·¥ç¥ó¤ÎÀ©¸æüËö¤Ç¤¢¤ë¾ì¹ç¡¢
266 ¤³¤ÎÀ©¸æüËö¤Î¥Õ¥©¥¢¥°¥é¥¦¥ó¥É¥×¥í¥»¥¹¥°¥ë¡¼¥×¤Ë¤¢¤ë
267 ³Æ¥×¥í¥»¥¹¤Ë
268 .B SIGHUP
269 ¥·¥°¥Ê¥ë¤¬Á÷¤é¤ì¡¢Ã¼Ëö¤¬¥»¥Ã¥·¥ç¥ó¤«¤éÀÚ¤êÎ¥¤µ¤ì¤ë¡£
270 ¤³¤ì¤Ë¤è¤ê¿·¤·¤¤À©¸æ¥×¥í¥»¥¹¤ò¼èÆÀ¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
271 .LP
272 .\"O If the exit of the process causes a process group to become orphaned,
273 .\"O and if any member of the newly orphaned process group is stopped,
274 .\"O then a
275 .\"O .B SIGHUP
276 .\"O signal followed by a
277 .\"O .B SIGCONT
278 .\"O signal will be
279 .\"O sent to each process in this process group.
280 ¥×¥í¥»¥¹¤¬½ªÎ»¤¹¤ë¤³¤È¤Ë¤è¤ê¡¢¥×¥í¥»¥¹¥°¥ë¡¼¥×¤¬¸ÉΩ¤·¤Æ¡¢
281 ¤½¤Î¥°¥ë¡¼¥×¤Î¥á¥ó¥Ð¡¼¤Î¤¦¤Á¤Î¤É¤ì¤«¤¬Ää»ß¤·¤¿¾ì¹ç¡¢
282 ¥×¥í¥»¥¹¥°¥ë¡¼¥×¤Î³Æ¥×¥í¥»¥¹¤ËÂФ·¤Æ
283 .B SIGHUP
284 ¥·¥°¥Ê¥ë¤¬Á÷¤é¤ì¡¢Â³¤¤¤Æ
285 .B SIGCONT
286 ¥·¥°¥Ê¥ë¤¬Á÷¤é¤ì¤ë¡£
287 .\"O See
288 .\"O .BR setpgid (2)
289 .\"O for an explanation of orphaned process groups.
290 ¸ÉΩ¤·¤¿ (orphaned) ¥×¥í¥»¥¹¥°¥ë¡¼¥×¤ÎÀâÌÀ¤Ï
291 .BR setpgid (2)
292 ¤ò»²¾È¡£
293 .\"O .SH "SEE ALSO"
294 .SH ´ØÏ¢¹àÌÜ
295 .BR _exit (2),
296 .BR setpgid (2),
297 .BR wait (2),
298 .BR atexit (3),
299 .BR on_exit (3),
300 .BR tmpfile (3)