1 .\" Copyright (C) 2001 Andries Brouwer <aeb@cwi.nl>.
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.
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.
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
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
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
31 .TH EXIT 3 2009-09-20 "Linux" "Linux Programmer's Manual"
34 .\"O exit \- cause normal process termination
35 exit \- ¥×¥í¥»¥¹¤ÎÀµ¾ï½ªÎ»
39 .B #include <stdlib.h>
41 .BI "void exit(int " status );
47 .\"O function causes normal process termination and the
48 .\"O value of \fIstatus & 0377\fP is returned to the parent
52 ´Ø¿ô¤Ï¡¢¥×¥í¥»¥¹¤òÀµ¾ï¤Ë½ªÎ»¤µ¤»¡¢
53 \fIstatus & 0377\fP ¤È¤¤¤¦Ãͤò¿Æ¥×¥í¥»¥¹¤ØÊÖ¤¹
57 .\"O All functions registered with
61 .\"O are called, in the reverse order of their registration.
62 .\"O (It is possible for one of these functions to use
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.)
74 ÅÐÏ¿¤µ¤ì¤¿Á´¤Æ¤Î´Ø¿ô¤Ï¡¢¤½¤ì¤é¤¬ÅÐÏ¿¤µ¤ì¤¿½çÈ֤ȵսç¤Ë¥³¡¼¥ë¤µ¤ì¤ë¡£
80 exit ½èÍýÃæ¤Ë¼Â¹Ô¤µ¤ì¤ëÄɲäδؿô¤òÅÐÏ¿¤¹¤ë¤³¤È¤¬¤Ç¤¤ë;
81 ¿·µ¬¤ËÅÐÏ¿¤µ¤ì¤¿´Ø¿ô¤Ï¡¢¤³¤Î¸å¤Ç¼Â¹Ô¤µ¤ì¤ë´Ø¿ô¥ê¥¹¥È¤ÎÀèƬ¤Ë
83 .\"O If one of these functions does not return
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
90 .\"O streams) is abandoned.
91 .\"O If a function has been registered multiple times using
95 .\"O then it is called as many times as it was registered.
96 ¤³¤ì¤é¤Î´Ø¿ô¤Î°ì¤Ä¤¬ÊÖ¤é¤Ê¤«¤Ã¤¿¾ì¹ç
99 ¤ò¸Æ¤Ó½Ð¤·¤¿¤ê¡¢¥·¥°¥Ê¥ë¤Ç¼«Ê¬¼«¿È¤ò kill ¤·¤¿¾ì¹ç)¡¢
100 »Ä¤ê¤Î´Ø¿ô¤Ï¤É¤ì¤â¸Æ¤Ó½Ð¤µ¤ì¤º¡¢¤½¤ì°Ê¹ß¤Î exit ½èÍý
103 ¥¹¥È¥ê¡¼¥à¤Î¥Õ¥é¥Ã¥·¥å¤Ê¤É) ¤ÏÃæ»ß¤µ¤ì¤ë¡£
108 ¤ò»È¤Ã¤ÆÊ£¿ô²óÅÐÏ¿¤µ¤ì¤Æ¤¤¤¿¾ì¹ç¡¢
109 ¤½¤Î´Ø¿ô¤ÏÅÐÏ¿¤µ¤ì¤¿¤Î¤ÈƱ¤¸²ó¿ô¤À¤±¸Æ¤Ó½Ð¤µ¤ì¤ë¡£
113 .\"O streams are flushed and closed.
114 .\"O Files created by
119 ¥¹¥È¥ê¡¼¥à¤ÏÁ´¤Æ¥Õ¥é¥Ã¥·¥å¤µ¤ì¤Æ¡¢¥¯¥í¡¼¥º¤µ¤ì¤ë¡£
121 ¤Ë¤è¤Ã¤ÆºîÀ®¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¤Ïºï½ü¤µ¤ì¤ë¡£
123 .\"O The C standard specifies two constants,
124 .\"O \fBEXIT_SUCCESS\fP and \fBEXIT_FAILURE\fP,
125 .\"O that may be passed to
127 .\"O to indicate successful or unsuccessful
128 .\"O termination, respectively.
134 ÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£¤½¤ì¤¾¤ìÀµ¾ï½ªÎ»¤È°Û¾ï½ªÎ»¤ò¼¨¤¹¤â¤Î¤Ç¡¢
136 ¤È¤·¤ÆÅϤ¹¤³¤È¤¬¤Ç¤¤ë¡£
137 .\"O .SH "RETURN VALUE"
141 .\"O function does not return.
144 .\"O .SH "CONFORMING TO"
146 SVr4, 4.3BSD, POSIX.1-2001, C89, C99.
150 .\"O It is undefined what happens if one of the
151 .\"O functions registered using
158 .\"O .BR longjmp (3).
162 ¤ò»È¤Ã¤ÆÅÐÏ¿¤µ¤ì¤¿´Ø¿ô¤ÎÃæ¤Ç
167 ²¿¤¬µ¯¤³¤ë¤«¤Ï̤ÄêµÁ¤Ç¤¢¤ë¡£
173 .\"O is slightly more portable
174 .\"O (to non-UNIX environments) than the use of 0 and some nonzero value
176 .\"O In particular, VMS uses a different convention.
180 ¤ò»È¤¦¤È¡¢0 ¤ä (1 ¤ä \-1 ¤È¤¤¤Ã¤¿) 0 °Ê³°¤ÎÃͤò»È¤¦¤Î¤ËÈæ¤Ù¤Æ
181 (UNIX °Ê³°¤Î´Ä¶¤Ë) °Ü¿¢¤¹¤ë¤Î¤¬¤¤¤¯¤é¤«´Êñ¤Ë¤Ê¤ë¡£
182 ÆÃ¤Ë VMS ¤ÏÊ̤ÎÊý¼°¤òÍѤ¤¤Æ¤¤¤ë¡£
184 .\"O BSD has attempted to standardize exit codes; see the file
185 .\"O .IR <sysexits.h> .
186 BSD ¤Ï½ªÎ»¥³¡¼¥É¤òɸ½à²½¤·¤è¤¦¤È¤·¤Æ¤¤¤ë;
192 .\"O the exit status must be transmitted to the
194 .\"O There are three cases.
195 .\"O If the parent has set
196 .\"O .BR SA_NOCLDWAIT ,
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
215 ¤Î¸å¡¢¿Æ¥×¥í¥»¥¹¤Ë½ªÎ»¥¹¥Æ¡¼¥¿¥¹¤¬ÅϤµ¤ì¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
216 ½ªÎ»¥¹¥Æ¡¼¥¿¥¹¤ÎÅϤ·Êý¤Ë¤Ï 3 ¤Ä¤Î¾ì¹ç¤¬¤¢¤ë¡£
225 ¥¹¥Æ¡¼¥¿¥¹¤ÏÇË´þ¤µ¤ì¤ë¡£
226 ¿Æ¥×¥í¥»¥¹¤¬»Ò¥×¥í¥»¥¹¤Î½ªÎ»¤òÂԤäƤ¤¤ë¾ì¹ç¡¢
227 ¿Æ¥×¥í¥»¥¹¤Ë½ªÎ»¥¹¥Æ¡¼¥¿¥¹¤¬ÅÁ¤¨¤é¤ì¤ë¡£
228 ¤É¤Á¤é¤Î¾ì¹ç¤Ç¤â exit ¤Î¥×¥í¥»¥¹¤Ïľ¤Á¤Ë½ªÎ»¤¹¤ë¡£
229 ¡Ö½ªÎ»¥¹¥Æ¡¼¥¿¥¹¤ò´ØÃΤ»¤º½ªÎ»¤âÂÔ¤¿¤Ê¤¤¡×
230 ¤È¤¤¤¦¤³¤È¤ò¿Æ¥×¥í¥»¥¹¤¬»Ø¼¨¤·¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢
231 exit ¥×¥í¥»¥¹¤Ï (½ªÎ»¥¹¥Æ¡¼¥¿¥¹¤òɽ¤¹ 1 ¥Ð¥¤¥È¤Î¤ß¤òÊÝ»ý¤¹¤ë)
232 ¡Ö¥¾¥ó¥Ó¡×¥×¥í¥»¥¹¤Ë¤Ê¤ë¡£
235 ´Ø¿ô¤ò¸Æ¤Ó½Ð¤¹¤³¤È¤Ç¡¢
236 ¿Æ¥×¥í¥»¥¹¤Ï½ªÎ»¥¹¥Æ¡¼¥¿¥¹¤òÃΤ뤳¤È¤¬¤Ç¤¤ë¡£
238 .\"O If the implementation supports the
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
248 ¥·¥°¥Ê¥ë¤Î¥µ¥Ý¡¼¥È¤¬¼ÂÁõ¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢
249 ¤³¤Î¥·¥°¥Ê¥ë¤Ï¿Æ¥×¥í¥»¥¹¤ËÁ÷¤é¤ì¤ë¡£
254 ¥·¥°¥Ê¥ë¤¬Á÷¤é¤ì¤ë¤«¤É¤¦¤«¤ÏÄêµÁ¤µ¤ì¤Æ¤¤¤Ê¤¤¡£
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
261 .\"O signal, and the terminal is disassociated
262 .\"O from this session, allowing it to be acquired by a new controlling
264 ¤½¤Î¥×¥í¥»¥¹¤¬¥»¥Ã¥·¥ç¥ó¤Î¥ê¡¼¥À¡¼¤Ç¡¢
265 ¤½¤Î¥×¥í¥»¥¹¤ÎÀ©¸æüËö¤¬¤½¤Î¥»¥Ã¥·¥ç¥ó¤ÎÀ©¸æüËö¤Ç¤¢¤ë¾ì¹ç¡¢
266 ¤³¤ÎÀ©¸æüËö¤Î¥Õ¥©¥¢¥°¥é¥¦¥ó¥É¥×¥í¥»¥¹¥°¥ë¡¼¥×¤Ë¤¢¤ë
269 ¥·¥°¥Ê¥ë¤¬Á÷¤é¤ì¡¢Ã¼Ëö¤¬¥»¥Ã¥·¥ç¥ó¤«¤éÀÚ¤êÎ¥¤µ¤ì¤ë¡£
270 ¤³¤ì¤Ë¤è¤ê¿·¤·¤¤À©¸æ¥×¥í¥»¥¹¤ò¼èÆÀ¤¹¤ë¤³¤È¤¬¤Ç¤¤ë¡£
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,
276 .\"O signal followed by a
279 .\"O sent to each process in this process group.
280 ¥×¥í¥»¥¹¤¬½ªÎ»¤¹¤ë¤³¤È¤Ë¤è¤ê¡¢¥×¥í¥»¥¹¥°¥ë¡¼¥×¤¬¸ÉΩ¤·¤Æ¡¢
281 ¤½¤Î¥°¥ë¡¼¥×¤Î¥á¥ó¥Ð¡¼¤Î¤¦¤Á¤Î¤É¤ì¤«¤¬Ää»ß¤·¤¿¾ì¹ç¡¢
282 ¥×¥í¥»¥¹¥°¥ë¡¼¥×¤Î³Æ¥×¥í¥»¥¹¤ËÂФ·¤Æ
284 ¥·¥°¥Ê¥ë¤¬Á÷¤é¤ì¡¢Â³¤¤¤Æ
289 .\"O for an explanation of orphaned process groups.
290 ¸ÉΩ¤·¤¿ (orphaned) ¥×¥í¥»¥¹¥°¥ë¡¼¥×¤ÎÀâÌÀ¤Ï