1 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\" Copyright (c) 1993 by Thomas Koenig <ig25@rz.uni-karlsruhe.de>
4 .\" and Copyright (c) 2004 by Michael Kerrisk <mtk.manpages@gmail.com>
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.
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.
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
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
27 .\" Modified Sat Jul 24 13:30:06 1993 by Rik Faith <faith@cs.unc.edu>
28 .\" Modified Sun Aug 21 17:42:42 1994 by Rik Faith <faith@cs.unc.edu>
29 .\" (Thanks to Koen Holtman <koen@win.tue.nl>)
30 .\" Modified Wed May 17 15:54:12 1995 by Rik Faith <faith@cs.unc.edu>
31 .\" To remove *'s from status in macros (Thanks to Michael Shields).
32 .\" Modified as suggested by Nick Duffek <nsd@bbc.com>, aeb, 960426
33 .\" Modified Mon Jun 23 14:09:52 1997 by aeb - add EINTR.
34 .\" Modified Thu Nov 26 02:12:45 1998 by aeb - add SIGCHLD stuff.
35 .\" Modified Mon Jul 24 21:37:38 2000 by David A. Wheeler
36 .\" <dwheeler@dwheeler.com> - noted thread issues.
37 .\" Modified 26 Jun 01 by Michael Kerrisk
38 .\" Added __WCLONE, __WALL, and __WNOTHREAD descriptions
39 .\" Modified 2001-09-25, aeb
40 .\" Modified 26 Jun 01 by Michael Kerrisk, <mtk.manpages@gmail.com>
41 .\" Updated notes on setting disposition of SIGCHLD to SIG_IGN
43 .\" Added waitid(2); added WCONTINUED and WIFCONTINUED()
44 .\" Added text on SA_NOCLDSTOP
45 .\" Updated discussion of SA_NOCLDWAIT to reflect 2.6 behavior
46 .\" Much other text rewritten
47 .\" 2005-05-10, mtk, __W* flags can't be used with waitid()
48 .\" 2008-07-04, mtk, removed erroneous text about SA_NOCLDSTOP
50 .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya all rights reserved.
51 .\" Japanese Version Copyright (c) 2005 Akihiro MOTOKI all rights reserved.
52 .\" Translated 1997-03-04, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
53 .\" Modified 2000-09-23, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
54 .\" Updated 2001-06-25, Kentaro Shirakata <argrath@ub32.org>
55 .\" Updated 2001-10-15, Kentaro Shirakata <argrath@ub32.org>
56 .\" Updated 2001-12-13, Kentaro Shirakata <argrath@ub32.org>
57 .\" Updated 2002-10-21, Kentaro Shirakata <argrath@ub32.org>
58 .\" Updated 2003-01-27, Kentaro Shirakata <argrath@ub32.org>
59 .\" Updated 2003-09-12, Kentaro Shirakata <argrath@ub32.org>
60 .\" Updated 2005-03-19, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
61 .\" Updated 2005-12-26, Akihiro MOTOKI
62 .\" Updated 2008-07-31, Akihiro MOTOKI, LDP v3.05
64 .\"WORD: signal handling ¥·¥°¥Ê¥ë½èÍý
65 .\"WORD: suspend Ää»ß(suspend)
66 .\"WORD: zombie ¥¾¥ó¥Ó(zombie)
67 .\"WORD: child process »Ò¥×¥í¥»¥¹
68 .\"WORD: process group ¥×¥í¥»¥¹¡¦¥°¥ë¡¼¥×
69 .\"WORD: process group ID ¥×¥í¥»¥¹¡¦¥°¥ë¡¼¥×ID
70 .\"WORD: stop Ää»ß(stop)
71 .\"WORD: effective user ID ¼Â¸ú¥æ¡¼¥¶¡¼ID
72 .\"WORD: block ¶Ø»ß(block)
74 .TH WAIT 2 2010-09-26 "Linux" "Linux Programmer's Manual"
77 .\"O wait, waitpid, waitid \- wait for process to change state
78 wait, waitpid, waitid \- ¥×¥í¥»¥¹¤Î¾õÂÖÊѲ½¤òÂÔ¤Ä
81 .B #include <sys/types.h>
83 .B #include <sys/wait.h>
85 .BI "pid_t wait(int *" "status" );
87 .BI "pid_t waitpid(pid_t " pid ", int *" status ", int " options );
89 .BI "int waitid(idtype_t " idtype ", id_t " id \
90 ", siginfo_t *" infop ", int " options );
93 .\"O Feature Test Macro Requirements for glibc (see
94 .\"O .BR feature_test_macros (7)):
95 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
96 .RB ( feature_test_macros (7)
105 _XOPEN_SOURCE\ >=\ 500 ||
106 _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
108 .\"O || /* Since glibc 2.12: */ _POSIX_C_SOURCE\ >=\ 200809L
109 || /* glibc 2.12 °Ê¹ß: */ _POSIX_C_SOURCE\ >=\ 200809L
115 .\"O All of these system calls are used to wait for state changes
116 .\"O in a child of the calling process, and obtain information
117 .\"O about the child whose state has changed.
118 .\"O A state change is considered to be: the child terminated;
119 .\"O the child was stopped by a signal; or the child was resumed by a signal.
120 .\"O In the case of a terminated child, performing a wait allows
121 .\"O the system to release the resources associated with the child;
122 .\"O if a wait is not performed, then the terminated child remains in
123 .\"O a "zombie" state (see NOTES below).
124 ¤³¤ì¤é¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï¤¤¤º¤ì¤â¡¢¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Î»Ò¥×¥í¥»¥¹¤Î
125 ¾õÂÖÊѲ½¤òÂÔ¤Á¡¢¾õÂÖ¤¬ÊѲ½¤·¤¿¤½¤Î»Ò¥×¥í¥»¥¹¤Î¾ðÊó¤ò¼èÆÀ¤¹¤ë¤Î¤Ë
127 ¾õÂÖÊѲ½¤È¤Ï°Ê²¼¤Î¤¤¤º¤ì¤«¤Ç¤¢¤ë:
128 »Ò¥×¥í¥»¥¹¤Î½ªÎ»¡¢¥·¥°¥Ê¥ë¤Ë¤è¤ë»Ò¥×¥í¥»¥¹¤ÎÄä»ß¡¢
129 ¥·¥°¥Ê¥ë¤Ë¤è¤ë»Ò¥×¥í¥»¥¹¤ÎºÆ³«¡£
130 »Ò¥×¥í¥»¥¹¤¬½ªÎ»¤·¤¿¾ì¹ç¤Ï¡¢wait ¤ò¼Â¹Ô¤¹¤ë¤³¤È¤Ç¡¢
131 ¥·¥¹¥Æ¥à¤¬¤½¤Î»Ò¥×¥í¥»¥¹¤Ë´ØÏ¢¤¹¤ë¥ê¥½¡¼¥¹¤ò²òÊü¤Ç¤¤ë¤è¤¦¤Ë¤Ê¤ë¡£
132 wait ¤¬¼Â¹Ô¤µ¤ì¤Ê¤«¤Ã¤¿¾ì¹ç¤Ë¤Ï¡¢½ªÎ»¤·¤¿»Ò¥×¥í¥»¥¹¤Ï
133 ¡Ö¥¾¥ó¥Ó¡×¾õÂ֤ǻĤ곤±¤ë (²¼µ¤ÎÃí°Õ¤Î¾Ï¤ò»²¾È¤Î¤³¤È)¡£
135 .\"O If a child has already changed state, then these calls return immediately.
136 .\"O Otherwise they block until either a child changes state or
137 .\"O a signal handler interrupts the call (assuming that system calls
138 .\"O are not automatically restarted using the
141 .\"O .BR sigaction (2)).
142 .\"O In the remainder of this page, a child whose state has changed
143 .\"O and which has not yet been waited upon by one of these system
146 »Ò¥×¥í¥»¥¹¤Î¾õÂÖÊѲ½¤¬¤¹¤Ç¤ËȯÀ¸¤·¤Æ¤¤¤¿¾ì¹ç¡¢¤³¤ì¤é¤Î¥³¡¼¥ë¤Ï
147 ¤¹¤°¤ËÉüµ¢¤¹¤ë¡£¤½¤ì°Ê³°¤Î¾ì¹ç¤Ï¡¢»Ò¥×¥í¥»¥¹¤Î¾õÂÖÊѲ½¤¬µ¯¤³¤ë¤«¡¢
148 ¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤Ë¤è¤ê¥·¥¹¥Æ¥à¥³¡¼¥ë¤¬ÃæÃǤµ¤ì¤ë¤Þ¤Ç¡¢
149 Ää»ß (block) ¤¹¤ë (¸å¼Ô¤Ï¡¢
153 ¥Õ¥é¥°¤Ë¤è¤ê¥·¥¹¥Æ¥à¥³¡¼¥ë¤¬¼«Æ°Åª¤ËºÆ¥¹¥¿¡¼¥È¤¹¤ë¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤Ê¤¤
155 °Ê²¼¤ÎÀâÌÀ¤Ç¤Ï¡¢¾õÂÖÊѲ½¤¬µ¯¤³¤Ã¤¿¤¬¤³¤ì¤é¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Î¤¤¤º¤ì¤«¤Ë
156 ¤è¤Ã¤ÆÂÔ¤¿¤ì¤Æ¤¤¤Ê¤¤»Ò¥×¥í¥»¥¹¤ò
159 .\"O .SS "wait() and waitpid()"
160 .SS "wait() ¤È waitpid()"
163 .\"O system call suspends execution of the calling process until one of its
164 .\"O children terminates.
166 .\"O .I wait(&status)
167 .\"O is equivalent to:
170 .\"O watpid(\-1, &status, 0);
173 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï¡¢»Ò¥×¥í¥»¥¹¤Î¤¤¤º¤ì¤«¤¬½ªÎ»¤¹¤ë¤Þ¤Ç
174 ¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î¼Â¹Ô¤ò°ì»þÄä»ß¤¹¤ë¡£
175 °Ê²¼¤ÎÆó¤Ä¤Î¸Æ¤Ó½Ð¤·¤ÏÅù²Á¤Ç¤¢¤ë:
180 waitpid(\-1, &status, 0);
185 .\"O system call suspends execution of the calling process until a
186 .\"O child specified by
188 .\"O argument has changed state.
191 .\"O waits only for terminated children, but this behavior is modifiable
194 .\"O argument, as described below.
198 °ú¤¿ô¤Ç»ØÄꤷ¤¿»Ò¥×¥í¥»¥¹¤Î¾õÂÖÊѲ½¤¬µ¯¤³¤ë¤Þ¤Ç¡¢
199 ¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î¼Â¹Ô¤ò°ì»þÄä»ß¤¹¤ë¡£¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¢
201 ¤Ï»Ò¥×¥í¥»¥¹¤Î½ªÎ»¤À¤±¤òÂԤĤ¬¡¢¤³¤ÎÆ°ºî¤Ï
203 °ú¤¿ô¤Ë¤è¤êÊѹ¹²Äǽ¤Ç¤¢¤ë¡£
209 ¤Ë»ØÄê¤Ç¤¤ëÃͤϰʲ¼¤ÎÄ̤ê:
211 .\"O meaning wait for any child process whose process group ID is
212 .\"O equal to the absolute value of
214 ¥×¥í¥»¥¹¥°¥ë¡¼¥×ID ¤¬
216 ¤ÎÀäÂÐÃͤËÅù¤·¤¤»Ò¥×¥í¥»¥¹¤Î¤¤¤º¤ì¤«¤¬½ªÎ»¤¹¤ë¤Þ¤Ç¤òÂԤġ£
218 .\"O meaning wait for any child process.
219 »Ò¥×¥í¥»¥¹¤Î¤É¤ì¤«¤¬½ªÎ»¤¹¤ë¤Þ¤ÇÂԤġ£
221 .\"O meaning wait for any child process whose process group ID is
222 .\"O equal to that of the calling process.
223 ¥×¥í¥»¥¹¥°¥ë¡¼¥×ID ¤¬¸Æ¤Ó½Ð¤·¤¿¥×¥í¥»¥¹¤Î¤â¤Î¤ÈÅù¤·¤¤
226 .\"O meaning wait for the child whose process ID is equal to the
231 ¤ËÅù¤·¤¤»Ò¥×¥í¥»¥¹¤òÂԤġ£
235 .\"O is an OR of zero or more of the following constants:
237 ¤ÎÃͤϼ¡¤ÎÄê¿ô¤Î 0 ¸Ä°Ê¾å¤ÎÏÀÍýϤǤ¢¤ë:
240 .\"O return immediately if no child has exited.
241 ¾õÂÖÊѲ½¤¬µ¯¤³¤Ã¤¿»Ò¥×¥í¥»¥¹¤¬¤Ê¤¤¾ì¹ç¤Ë¤¹¤°¤ËÉüµ¢¤¹¤ë¡£
244 .\"O also return if a child has stopped
245 .\"O (but not traced via
246 .\"O .BR ptrace (2)).
249 .\"O children which have stopped is provided
250 .\"O even if this option is not specified.
251 »Ò¥×¥í¥»¥¹¤¬Ää»ß¤·¤¿¾ì¹ç¤Ë¤âÉüµ¢¤¹¤ë (»Ò¥×¥í¥»¥¹¤¬
253 ¤Ç¥È¥ì¡¼¥¹¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ï½ü¤¯)¡£
254 ¤³¤Î¥ª¥×¥·¥ç¥ó¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ç¤â¡¢Ää»ß¤·¤¿¥×¥í¥»¥¹¤¬
255 ¡Ö¥È¥ì¡¼¥¹ (traced)¡×¤µ¤ì¤Æ¤¤¤ì¤Ð¡¢»Ò¥×¥í¥»¥¹¤Î¾õÂÖ¤¬Êó¹ð¤µ¤ì¤ë¡£
257 .\"O .BR WCONTINUED " (Since Linux 2.6.10)"
258 .BR WCONTINUED " (Linux 2.6.10 °Ê¹ß)"
259 .\"O also return if a stopped child has been resumed by delivery of
263 ¤ÎÇÛÁ÷¤Ë¤è¤êºÆ³«¤·¤¿¾ì¹ç¤Ë¤âÉüµ¢¤¹¤ë¡£
265 .\"O (For Linux-only options, see below.)
266 (Linux ÀìÍÑ¥ª¥×¥·¥ç¥ó¤Ë¤Ä¤¤¤Æ¤Ï¸å½Ò¤¹¤ë)
274 .\"O store status information in the \fIint\fP to which it points.
282 ¤Ç»Ø¤¹ \fIint\fP ¤Ë¾õÂÖ¾ðÊó¤ò³ÊǼ¤¹¤ë¡£
283 .\"O This integer can be inspected with the following macros (which
284 .\"O take the integer itself as an argument, not a pointer to it,
288 .\"O .BR waitpid ()!):
289 ¤³¤ÎÀ°¿ô¤Ï°Ê²¼¤Î¥Þ¥¯¥í¤ò»È¤Ã¤Æ¸¡ºº¤Ç¤¤ë¡£
290 (¤³¤ì¤é¤Î¥Þ¥¯¥í¤Î°ú¤¿ô¤Ë¤Ï¡¢
294 ¤¬½ñ¤¹þ¤ó¤ÀÀ°¿ô¤½¤Î¤â¤Î¤ò»ØÄꤹ¤ë¡£¥Ý¥¤¥ó¥¿¤Ç¤Ï¤Ê¤¤!)
296 .BI WIFEXITED( status )
297 .\"O returns true if the child terminated normally, that is,
302 .\"O or by returning from main().
303 »Ò¥×¥í¥»¥¹¤¬Àµ¾ï¤Ë½ªÎ»¤·¤¿¾ì¹ç¤Ë¿¿¤òÊÖ¤¹¡£
308 ¤¬¸Æ¤Ó½Ð¤µ¤ì¤¿¾ì¹ç¡¢¤â¤·¤¯¤Ï
309 main() ¤«¤éÉüµ¢¤·¤¿¾ì¹ç¤Ç¤¢¤ë¡£
311 .BI WEXITSTATUS( status )
312 .\"O returns the exit status of the child.
313 .\"O This consists of the least significant 8 bits of the
315 .\"O argument that the child specified in a call to
319 .\"O or as the argument for a return statement in main().
320 .\"O This macro should only be employed if
323 »Ò¥×¥í¥»¥¹¤Î½ªÎ»¥¹¥Æ¡¼¥¿¥¹¤òÊÖ¤¹¡£
326 °ú¤¿ô¤Î²¼°Ì 8¥Ó¥Ã¥È¤Ç¹½À®¤µ¤ì¤Æ¤ª¤ê¡¢
330 ¤Î¸Æ¤Ó½Ð¤·»þ¤ËÅϤµ¤ì¤¿ÃÍ¡¢¤â¤·¤¯¤Ï main() ¤Î return ʸ¤Î
331 °ú¤¿ô¤È¤·¤Æ»ØÄꤵ¤ì¤¿ÃͤǤ¢¤ë¡£
332 ¤³¤Î¥Þ¥¯¥í¤ò»ÈÍѤ¹¤ë¤Î¤Ï
334 ¤¬¿¿¤òÊÖ¤·¤¿¾ì¹ç¤À¤±¤Ë¤¹¤Ù¤¤Ç¤¢¤ë¡£
336 .BI WIFSIGNALED( status )
337 .\"O returns true if the child process was terminated by a signal.
338 »Ò¥×¥í¥»¥¹¤¬¥·¥°¥Ê¥ë¤Ë¤è¤ê½ªÎ»¤·¤¿¾ì¹ç¤Ë¿¿¤òÊÖ¤¹¡£
340 .BI WTERMSIG( status )
341 .\"O returns the number of the signal that caused the child process to
343 .\"O This macro should only be employed if
346 »Ò¥×¥í¥»¥¹½ªÎ»¤Î¸¶°ø¤È¤Ê¤Ã¤¿¥·¥°¥Ê¥ë¤ÎÈÖ¹æ¤òÊÖ¤¹¡£
347 ¤³¤Î¥Þ¥¯¥í¤ò»ÈÍѤ¹¤ë¤Î¤Ï
349 ¤¬¿¿¤òÊÖ¤·¤¿¾ì¹ç¤À¤±¤Ë¤¹¤Ù¤¤Ç¤¢¤ë¡£
351 .BI WCOREDUMP( status )
352 .\"O returns true if the child produced a core dump.
353 .\"O This macro should only be employed if
356 .\"O This macro is not specified in POSIX.1-2001 and is not available on
357 .\"O some UNIX implementations (e.g., AIX, SunOS).
358 .\"O Only use this enclosed in #ifdef WCOREDUMP ... #endif.
359 »Ò¥×¥í¥»¥¹¤¬¥³¥¢¥À¥ó¥×¤òÀ¸À®¤·¤¿¾ì¹ç¤Ë¿¿¤òÊÖ¤¹¡£
360 ¤³¤Î¥Þ¥¯¥í¤ò»ÈÍѤ¹¤ë¤Î¤Ï
362 ¤¬¿¿¤òÊÖ¤·¤¿¾ì¹ç¤À¤±¤Ë¤¹¤Ù¤¤Ç¤¢¤ë¡£
363 ¤³¤Î¥Þ¥¯¥í¤Ï POSIX.1-2001 ¤Ç¤Ïµ¬Äꤵ¤ì¤Æ¤ª¤é¤º¡¢
364 (AIX, SunOS ¤Ê¤É¤Î) ¤¤¤¯¤Ä¤«¤Î UNIX ¤Î¼ÂÁõ¤Ç¤ÏÍøÍѤǤ¤Ê¤¤¡£
365 ɬ¤º #ifdef WCOREDUMP ... #endif ¤Ç³ç¤Ã¤Æ»ÈÍѤ¹¤ë¤³¤È¡£
367 .BI WIFSTOPPED( status )
368 .\"O returns true if the child process was stopped by delivery of a signal;
369 .\"O this is only possible if the call was done using
371 .\"O or when the child is being traced (see
372 .\"O .BR ptrace (2)).
373 »Ò¥×¥í¥»¥¹¤¬¥·¥°¥Ê¥ë¤ÎÇÛÁ÷¤Ë¤è¤êÄä»ß¤·¤¿¾ì¹ç¤Ë¿¿¤òÊÖ¤¹¡£
374 ¤³¤ì¤¬¿¿¤Ë¤Ê¤ë¤Î¤Ï¡¢¥·¥¹¥Æ¥à¥³¡¼¥ë¤¬
376 ¤ò»ØÄꤷ¤Æ¸Æ¤Ó½Ð¤µ¤ì¤¿¾ì¹ç¤«¡¢»Ò¥×¥í¥»¥¹¤¬¥È¥ì¡¼¥¹¤µ¤ì¤Æ¤¤¤ë¾ì¹ç
380 .BI WSTOPSIG( status )
381 .\"O returns the number of the signal which caused the child to stop.
382 .\"O This macro should only be employed if
385 »Ò¥×¥í¥»¥¹¤òÄä»ß¤µ¤»¤¿¥·¥°¥Ê¥ë¤ÎÈÖ¹æ¤òÊÖ¤¹¡£
386 ¤³¤Î¥Þ¥¯¥í¤ò»ÈÍѤ¹¤ë¤Î¤Ï
388 ¤¬ 0 °Ê³°¤òÊÖ¤·¤¿¾ì¹ç¤À¤±¤Ë¤¹¤Ù¤¤Ç¤¢¤ë¡£
390 .BI WIFCONTINUED( status )
391 .\"O (since Linux 2.6.10)
393 .\"O returns true if the child process was resumed by delivery of
397 ¤ÎÇÛÁ÷¤Ë¤è¤êºÆ³«¤·¤¿¾ì¹ç¤Ë¿¿¤òÊÖ¤¹¡£
401 .\"O system call (available since Linux 2.6.9) provides more precise
402 .\"O control over which child state changes to wait for.
404 ¥·¥¹¥Æ¥à¥³¡¼¥ë (Linux 2.6.9 °Ê¹ß¤ÇÍøÍѲÄǽ) ¤ò»È¤¦¤È¡¢
405 »Ò¥×¥í¥»¥¹¤Î¤É¤Î¾õÂÖÊѲ½¤òÂԤĤ«¤Ë¤Ä¤¤¤Æ¤è¤êºÙ¤«¤ÊÀ©¸æ¤¬¤Ç¤¤ë¡£
411 .\"O arguments select the child(ren) to wait for, as follows:
416 ¤Ç¤É¤Î»Ò¥×¥í¥»¥¹¤òÂԤĤ«¤òÁªÂò¤¹¤ë:
417 .IP "\fIidtype\fP == \fBP_PID\fP"
418 .\"O Wait for the child whose process ID matches
422 ¤È°ìÃפ¹¤ë»Ò¥×¥í¥»¥¹¤òÂԤġ£
423 .IP "\fIidtype\fP == \fBP_PGID\fP"
424 .\"O Wait for any child whose process group ID matches
426 ¥×¥í¥»¥¹¥°¥ë¡¼¥×ID ¤¬
428 ¤È°ìÃפ¹¤ë»Ò¥×¥í¥»¥¹¤òÂԤġ£
429 .IP "\fIidtype\fP == \fBP_ALL\fP"
430 .\"O Wait for any child;
433 »Ò¥×¥í¥»¥¹Á´Éô¤òÂоݤËÂԤġ£
437 .\"O The child state changes to wait for are specified by ORing
438 .\"O one or more of the following flags in
440 »Ò¥×¥í¥»¥¹¤Î¤É¤Î¾õÂÖÊѲ½¤òÂԤĤ«¤Ï°Ê²¼¤Î¥Õ¥é¥°¤Ç»ØÄꤹ¤ë
442 ¤Ë¤Ï 1¸Ä°Ê¾å¤Î¥Õ¥é¥°¤ÎÏÀÍýϤò¤È¤Ã¤Æ»ØÄꤹ¤ë):
445 .\"O Wait for children that have terminated.
446 »Ò¥×¥í¥»¥¹¤Î½ªÎ»¤òÂԤġ£
449 .\"O Wait for children that have been stopped by delivery of a signal.
450 »Ò¥×¥í¥»¥¹¤¬¥·¥°¥Ê¥ë¤ÎÇÛÁ÷¤Ë¤è¤êÄä»ß¤¹¤ë¤Î¤òÂԤġ£
453 .\"O Wait for (previously stopped) children that have been
454 .\"O resumed by delivery of
456 (Ää»ß¤·¤Æ¤¤¤¿) »Ò¥×¥í¥»¥¹¤¬
458 ¤¬ÇÛÁ÷¤µ¤ì¤ÆºÆ³«¤¹¤ë¤Î¤òÂԤġ£
460 .\"O The following flags may additionally be ORed in
462 ¤µ¤é¤Ë°Ê²¼¤Î¥Õ¥é¥°¤òÏÀÍýϤηÁ¤Ç
473 .\"O Leave the child in a waitable state; a later wait call
474 .\"O can be used to again retrieve the child status information.
475 waitable ¾õÂÖ¤Î¥×¥í¥»¥¹¤ò¤½¤Î¤Þ¤Þ¤Ë¤¹¤ë¡£¤³¤Î¸å¤Ç wait ¥³¡¼¥ë¤ò
476 »È¤Ã¤Æ¡¢Æ±¤¸»Ò¥×¥í¥»¥¹¤Î¾õÂÖ¾ðÊó¤ò¤â¤¦°ìÅÙ¼èÆÀ¤¹¤ë¤³¤È¤¬¤Ç¤¤ë¡£
478 .\"O Upon successful return,
480 .\"O fills in the following fields of the
482 .\"O structure pointed to by
490 ¹½Â¤ÂΤΰʲ¼¤Î¥Õ¥£¡¼¥ë¥É¤òÀßÄꤹ¤ë:
493 .\"O The process ID of the child.
494 »Ò¥×¥í¥»¥¹¤Î¥×¥í¥»¥¹ID¡£
497 .\"O The real user ID of the child.
498 .\"O (This field is not set on most other implementations.)
499 »Ò¥×¥í¥»¥¹¤Î¼Â¥æ¡¼¥¶ID
500 (¤³¤Î¥Õ¥£¡¼¥ë¥É¤Ï¾¤Î¤Û¤È¤ó¤É¤Î¼ÂÁõ¤Ç¤ÏÀßÄꤵ¤ì¤Ê¤¤)¡£
510 .\"O Either the exit status of the child, as given to
514 .\"O or the signal that caused the child to terminate, stop, or continue.
517 .\"O field can be used to determine how to interpret this field.
521 ¤Ë»ØÄꤵ¤ì¤¿»Ò¥×¥í¥»¥¹¤Î½ªÎ»¥¹¥Æ¡¼¥¿¥¹¡¢¤â¤·¤¯¤Ï
522 »Ò¥×¥í¥»¥¹¤Î½ªÎ»¡¢Ää»ß¡¢ºÆ³«¤Î¸¶°ø¤È¤Ê¤Ã¤¿¥·¥°¥Ê¥ë¤¬ÀßÄꤵ¤ì¤ë¡£
523 ¤³¤Î¥Õ¥£¡¼¥ë¥É¤ò¤É¤¦²ò¼á¤¹¤ë¤«¤Ï¡¢
525 ¥Õ¥£¡¼¥ë¥É¤ò»²¾È¤·¤Æ·è¤á¤ë¤³¤È¤¬¤Ç¤¤ë¡£
533 .\"O (child killed by signal);
535 .\"O (child killed by signal, and dumped core);
537 .\"O (child stopped by signal);
539 .\"O (traced child has trapped); or
540 .\"O .B CLD_CONTINUED
541 .\"O (child continued by
543 °Ê²¼¤Î¤¤¤º¤ì¤«¤¬ÀßÄꤵ¤ì¤ë:
549 (¥·¥°¥Ê¥ë¤Ë¤è¤ê»Ò¥×¥í¥»¥¹¤¬ kill ¤µ¤ì¤¿);
551 (¥·¥°¥Ê¥ë¤Ë¤è¤ê»Ò¥×¥í¥»¥¹¤¬ kill ¤µ¤ì¡¢¥³¥¢¡¦¥À¥ó¥×¤¬¹Ô¤ï¤ì¤¿);
553 (¥·¥°¥Ê¥ë¤Ë¤è¤ê»Ò¥×¥í¥»¥¹¤¬Ää»ß¤·¤¿);
555 (¥È¥ì¡¼¥¹¤µ¤ì¤Æ¤¤¤¿»Ò¥×¥í¥»¥¹¤¬¥È¥é¥Ã¥×¤ò¼õ¿®¤·¤¿);
558 ¤Ë¤è¤ê»Ò¥×¥í¥»¥¹¤¬ºÆ³«¤µ¤ì¤¿)¡£
562 .\"O was specified in
564 .\"O and there were no children in a waitable state, then
566 .\"O returns 0 immediately and
567 .\"O the state of the
569 .\"O structure pointed to by
576 waitable ¾õÂÖ¤Î»Ò¥×¥í¥»¥¹¤¬¤Ê¤«¤Ã¤¿¾ì¹ç¤Ë¤Ï¡¢
578 ¤Ï¤¹¤°¤Ë 0 ¤òÊÖ¤¹¡£¤³¤Î¤È¤¡¢
582 ¹½Â¤ÂΤÎÆâÍƤÏÉÔÄê¤Ç¤¢¤ë¡£
583 .\"O .\" POSIX.1-2001 leaves this possibility unspecified; most
584 .\"O .\" implementations (including Linux) zero out the structure
585 .\"O .\" in this case, but at at least one implementation (AIX 5.1)
586 .\"O .\" does not -- MTK Nov 04
587 .\" POSIX.1-2001 ¤Ç¤Ï¡¢ÉÔÄê¤Î²ÄǽÀ¤ò»Ä¤·¤Æ¤¤¤ë¡£
588 .\" (Linux ¤ò´Þ¤à) ¤Û¤È¤ó¤É¤Î¼ÂÁõ¤Ç¤Ï¡¢¤³¤Î¾ì¹ç¤Ë¹½Â¤ÂΤò 0 ¤ÇËä¤á¤ë¤¬¡¢
589 .\" ¾¯¤Ê¤¯¤È¤â°ì¤Ä¤Î¼ÂÁõ (AIX 5.1) ¤Ç¤Ï¤½¤¦¤Ê¤é¤Ê¤¤¡£ -- MTK Nov 04
590 .\"O To distinguish this case from that where a child was in a
591 .\"O waitable state, zero out the
593 .\"O field before the call and check for a nonzero value in this field
594 .\"O after the call returns.
595 ¤³¤Î¾ì¹ç¤ò waitable ¾õÂÖ¤Î»Ò¥×¥í¥»¥¹¤¬¤¢¤Ã¤¿¾ì¹ç¤È¶èÊ̤¹¤ë¤Ë¤Ï¡¢
599 ¤ò 0 ¤Ë¤·¤Æ¤ª¤¡¢¥³¡¼¥ë¤¬Éüµ¢¤·¤¿¸å¤Ç¤³¤Î¥Õ¥£¡¼¥ë¥É¤¬ 0 °Ê³°¤ÎÃͤ«¤É¤¦¤«
600 ¤ò¥Á¥§¥Ã¥¯¤¹¤ì¤Ð¤è¤¤¡£
601 .\"O .SH "RETURN VALUE"
604 .\"O on success, returns the process ID of the terminated child;
605 .\"O on error, \-1 is returned.
606 À®¸ù¤¹¤ë¤È¡¢½ªÎ»¤·¤¿»Ò¥×¥í¥»¥¹¤Î¥×¥í¥»¥¹ID ¤òÊÖ¤¹¡£
607 ¥¨¥é¡¼¤Î¾ì¹ç \-1 ¤òÊÖ¤¹¡£
610 .\"O on success, returns the process ID of the child whose state has changed;
613 .\"O was specified and one or more child(ren) specified by
615 .\"O exist, but have not yet changed state, then 0 is returned.
616 .\"O On error, \-1 is returned.
617 À®¸ù¤¹¤ë¤È¡¢¾õÂÖ¤¬ÊѲ½¤·¤¿»Ò¥×¥í¥»¥¹¤Î¥×¥í¥»¥¹ID ¤òÊÖ¤¹¡£
621 ¤Ç»Ø¼¨¤µ¤ì¤¿»Ò¥×¥í¥»¥¹¤¬°ì¤Ä°Ê¾å¸ºß¤¹¤ë¤¬¡¢¤É¤Î»Ò¥×¥í¥»¥¹¤Ç¤â
622 ¾õÂÖÊѲ½¤¬µ¯¤³¤Ã¤Æ¤¤¤Ê¤«¤Ã¤¿¾ì¹ç¤Ï¡¢ 0 ¤òÊÖ¤¹¡£
623 ¥¨¥é¡¼¤Î¾ì¹ç \-1 ¤òÊÖ¤¹¡£
626 .\"O returns 0 on success or
629 .\"O was specified and no child(ren) specified by
631 .\"O has yet changed state;
632 .\"O on error, \-1 is returned.
633 À®¸ù¤¹¤ë¤È 0 ¤òÊÖ¤¹¡£
637 ¤Ç»Ø¼¨¤µ¤ì¤¿»Ò¥×¥í¥»¥¹¤Ç¾õÂÖÊѲ½¤¬µ¯¤³¤Ã¤Æ¤¤¤Ê¤«¤Ã¤¿¾ì¹ç¤Ë¤â
639 ¥¨¥é¡¼¤Î¾ì¹ç \-1 ¤òÊÖ¤¹¡£
640 .\" FIXME: As reported by Vegard Nossum, if infop is NULL, then waitid()
641 .\" returns the PID of the child. Either this is a bug, or it is intended
642 .\" behavior that needs to be documented. See my Jan 2009 LKML mail
643 .\" "waitid() return value strangeness when infop is NULL".
644 .\"O Each of these calls sets
646 .\"O to an appropriate value in the case of an error.
647 ¥¨¥é¡¼¤Î¾ì¹ç¡¢¤³¤ì¤é¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï¤¤¤º¤ì¤â
649 ¤ËŬÀÚ¤ÊÃͤòÀßÄꤹ¤ë¡£
659 .\"O The calling process does not have any unwaited-for children.
660 ¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Ë¤Ï¡¢wait ¤ò¹Ô¤Ã¤Æ¤¤¤Ê¤¤»Ò¥×¥í¥»¥¹¤Ï¤Ê¤¤¡£
672 .\"O The process specified by
674 .\"O .RB ( waitpid ())
679 .\"O .RB ( waitid ())
680 .\"O does not exist or is not a child of the calling process.
681 .\"O (This can happen for one's own child if the action for
685 .\"O See also the \fILinux Notes\fP section about threads.)
693 ¤Ç»ØÄꤷ¤¿¥×¥í¥»¥¹¤¬Â¸ºß¤·¤Ê¤¤¤«¡¢¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Î»Ò¥×¥í¥»¥¹¤Ç¤Ê¤¤
697 ¤òÀßÄꤷ¤¿¾ì¹ç¤Ë¤Ï¡¢¼«Ê¬¼«¿È¤Î»Ò¥×¥í¥»¥¹¤Ç¤âµ¯¤³¤ê¤¦¤ë¡£
698 ¥¹¥ì¥Ã¥É¤Ë´Ø¤·¤Æ¤Ï¡ÖLinux ¤Ç¤ÎÃí°Õ¡×¤ÎÀá¤â»²¾È¤¹¤ë¤³¤È)¡£
702 .\"O was not set and an unblocked signal or a
704 .\"O was caught; see.
707 ¤¬ÀßÄꤵ¤ì¤Æ¤ª¤é¤º¡¢¶Ø»ß (block) ¤µ¤ì¤Æ¤¤¤Ê¤¤¥·¥°¥Ê¥ë¤ä
716 .\"O argument was invalid.
719 .\"O .SH "CONFORMING TO"
721 SVr4, 4.3BSD, POSIX.1-2001.
724 .\"O A child that terminates, but has not been waited for becomes a "zombie".
725 .\"O The kernel maintains a minimal set of information about the zombie
726 .\"O process (PID, termination status, resource usage information)
727 .\"O in order to allow the parent to later perform a wait to obtain
728 .\"O information about the child.
729 .\"O As long as a zombie is not removed from the system via a wait,
730 .\"O it will consume a slot in the kernel process table, and if
731 .\"O this table fills, it will not be possible to create further processes.
732 .\"O If a parent process terminates, then its "zombie" children (if any)
735 .\"O which automatically performs a wait to remove the zombies.
736 ½ªÎ»¤·¤¿¤¬¡¢wait ¤µ¤ì¤Æ¤¤¤Ê¤¤»Ò¥×¥í¥»¥¹¤Ï¡Ö¥¾¥ó¥Ó¡×¤Ë¤Ê¤ë¡£
737 ¸å¤Ç¿Æ¥×¥í¥»¥¹¤¬ wait ¤ò¼Â¹Ô¤·¤Æ»Ò¥×¥í¥»¥¹¤Ë¤Ä¤¤¤Æ¤Î¾ðÊó¤ò¼èÆÀ¤Ç¤¤ë¤è¤¦¤Ë¡¢
738 ¥«¡¼¥Í¥ë¤Ï¥¾¥ó¥Ó¥×¥í¥»¥¹¤Ë¤Ä¤¤¤ÆºÇ¾®¸Â¤Î¾ðÊó (PID¡¢½ªÎ»¥¹¥Æ¡¼¥¿¥¹¡¢
739 ¥ê¥½¡¼¥¹»ÈÍѾõ¶·) ¤òÊÝ»ý¤¹¤ë¡£
740 ¥¾¥ó¥Ó¥×¥í¥»¥¹¤Ï¡¢ wait ¤Ë¤è¤Ã¤Æ¥·¥¹¥Æ¥à¤«¤éºï½ü¤µ¤ì¤Ê¤¤¸Â¤ê¡¢
741 ¥«¡¼¥Í¥ë¤Î¥×¥í¥»¥¹¥Æ¡¼¥Ö¥ë¤Î 1 ¥¨¥ó¥È¥ê¤ò¾ÃÈñ¤¹¤ë¡£¤³¤Î¥×¥í¥»¥¹¥Æ¡¼¥Ö¥ë¤¬
742 °ìÇդˤʤë¤È¡¢¿·¤¿¤Ë¥×¥í¥»¥¹¤òºî¤ë¤³¤È¤¬¤Ç¤¤Ê¤¯¤Ê¤ë¡£
743 ¿Æ¥×¥í¥»¥¹¤¬½ªÎ»¤¹¤ë¤È¡¢¤½¤Î¿Æ¥×¥í¥»¥¹¤Î¡Ö¥¾¥ó¥Ó¡×¤Î
744 »Ò¥×¥í¥»¥¹¤Ï (¤â¤·¤¢¤ì¤Ð)
748 ¤Ï wait ¤ò¼«Æ°Åª¤Ë¼Â¹Ô¤·¡¢¥¾¥ó¥Ó¤òºï½ü¤¹¤ë¡£
750 .\"O POSIX.1-2001 specifies that if the disposition of
759 .\"O .BR sigaction (2)),
760 .\"O then children that terminate do not become zombies and a call to
764 .\"O will block until all children have terminated, and then fail with
768 POSIX.1-2001 ¤Ç¤Ï°Ê²¼¤Î¤è¤¦¤Ëµ¬Äꤵ¤ì¤Æ¤¤¤ë¡£
776 ¥Õ¥é¥°¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç
778 »²¾È)¡¢½ªÎ»¤·¤¿»Ò¥×¥í¥»¥¹¤Ï¥¾¥ó¥Ó¤Ë¤Ï¤Ê¤é¤º¡¢
782 ¤Î¸Æ¤Ó½Ð¤·¤ÏÁ´¤Æ¤Î»Ò¥×¥í¥»¥¹¤¬½ªÎ»¤¹¤ë¤Þ¤ÇÄä»ß¤·¡¢
783 »Ò¥×¥í¥»¥¹¤¬Á´Éô½ªÎ»¤·¤¿¸å
788 .\"O (The original POSIX standard left the behavior of setting
793 .\"O Note that even though the default disposition of
795 .\"O is "ignore", explicitly setting the disposition to
797 .\"O results in different treatment of zombie process children.)
798 (¤â¤È¤â¤È¤Î POSIX ɸ½à¤Ï
802 ¤òÀßÄꤷ¤¿¾ì¹ç¤Î¿¶¤ëÉñ¤¤¤ò̤µ¬Äê¤Î¤Þ¤Þ¤Ë¤·¤Æ¤¤¤ë¡£
804 ¤Î¥Ç¥Õ¥©¥ë¥È¤ÎÆ°ºî¤¬¡Ö̵»ë¡×¤Ç¤¢¤ë¤Ë¤â¤«¤«¤ï¤é¤º¡¢
808 ¤òÌÀ¼¨Åª¤ËÀßÄꤷ¤¿¾ì¹ç¤Ë¤Ï¥¾¥ó¥Ó¥×¥í¥»¥¹¤Î»Ò¥×¥í¥»¥¹¤Î°·¤¤¤¬
809 °Û¤Ê¤ëÅÀ¤ËÃí°Õ¤¹¤ë¤³¤È¡£)
810 .\"O Linux 2.6 conforms to this specification.
811 .\"O However, Linux 2.4 (and earlier) does not:
812 Linux 2.6 ¤Ï¤³¤Î»ÅÍͤ˽àµò¤·¤Æ¤¤¤ë¡£
813 ¤·¤«¤·¡¢Linux 2.4 (¤È¤½¤ì°ÊÁ°¤Î¥Ð¡¼¥¸¥ç¥ó) ¤Ï¤½¤¦¤Ç¤Ï¤Ê¤¤:
818 .\"O call is made while
820 .\"O is being ignored, the call behaves just as though
822 .\"O were not being ignored, that is, the call blocks until the next child
823 .\"O terminates and then returns the process ID and status of that child.
831 ¤¬Ìµ»ë¤µ¤ì¤Æ¤¤¤Ê¤¤¤«¤Î¤è¤¦¤Ë¿¶¤ëÉñ¤¦¡£
832 ¤Ä¤Þ¤ê¡¢¸Æ¤Ó½Ð¤·¤Ë¤è¤Ã¤Æ¼¡¤Î»Ò¥×¥í¥»¥¹¤Î½ªÎ»¤Þ¤Ç¥Ö¥í¥Ã¥¯¤µ¤ì¡¢
833 ½ªÎ»¤·¤¿»Ò¥×¥í¥»¥¹¤Î PID ¤È¾õÂÖ¤¬ÊÖ¤µ¤ì¤ë¡£
836 .\"O In the Linux kernel, a kernel-scheduled thread is not a distinct
837 .\"O construct from a process.
838 .\"O Instead, a thread is simply a process
839 .\"O that is created using the Linux-unique
841 .\"O system call; other routines such as the portable
842 .\"O .BR pthread_create (3)
843 .\"O call are implemented using
845 .\"O they cannot be used with
847 Linux ¥«¡¼¥Í¥ë¤Ç¤Ï¡¢¥«¡¼¥Í¥ë¤Ë¤è¤Ã¤Æ¥¹¥±¥¸¥å¡¼¥ë¤µ¤ì¤ë¥¹¥ì¥Ã¥É¤Ï
848 ¥×¥í¥»¥¹¤ÈÌÀ³Î¤Ë¶èÊ̤Ǥ¤ë¹½À®Í×ÁǤǤϤʤ¤¡£¥¹¥ì¥Ã¥É¤Ï Linux ¸ÇͤÎ
850 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤ò»ÈÍѤ·¤ÆÀ¸À®¤µ¤ì¤ë¥×¥í¥»¥¹¤Ë²á¤®¤Ê¤¤¡£
852 .BR pthread_create (3)
853 ¥³¡¼¥ë¤Î¤è¤¦¤Ê¾¤Î¥ë¡¼¥Á¥ó¤Ï
855 ¤ò»ÈÍѤ·¤Æ¼ÂÁõ¤µ¤ì¤Æ¤¤¤ë;
858 ¤ò»È¤¦¤³¤È¤Ï¤Ç¤¤Ê¤¤¡£
859 .\"O Before Linux 2.4, a thread was just a special case of a process,
860 .\"O and as a consequence one thread could not wait on the children
861 .\"O of another thread, even when the latter belongs to the same thread group.
862 Linux 2.4 ¤è¤êÁ°¤Ç¤Ï¡¢¥¹¥ì¥Ã¥É¤Ïñ¤ËÆüì¤Ê¥×¥í¥»¥¹¤Ç¤¢¤Ã¤¿¤Î¤Ç¡¢
863 Î㤨Ʊ¤¸¥¹¥ì¥Ã¥É¥°¥ë¡¼¥×¤Ç¤¢¤Ã¤Æ¤â¡¢
864 ¤¢¤ë¥¹¥ì¥Ã¥É¤¬Ê̤Υ¹¥ì¥Ã¥É¤Î»Ò¥×¥í¥»¥¹¤¬½ªÎ»¤¹¤ë¤Î¤òÂԤĤ³¤È¤Ï½ÐÍè¤Ê¤«¤Ã¤¿¡£
865 .\"O However, POSIX prescribes such functionality, and since Linux 2.4
866 .\"O a thread can, and by default will, wait on children of other threads
867 .\"O in the same thread group.
868 ¤·¤«¤·¡¢POSIX ¤Ç¤Ï¤³¤Î¤è¤¦¤Êµ¡Ç½¤òµ¬Äꤷ¤Æ¤ª¤ê¡¢
869 Linux 2.4 °Ê¹ß¤Ç¤Ï¡¢¤¢¤ë¥¹¥ì¥Ã¥É¤¬Æ±¤¸¥¹¥ì¥Ã¥É¥°¥ë¡¼¥×¤Î¾¤Î¥¹¥ì¥Ã¥É¤Î
870 »Ò¥×¥í¥»¥¹¤¬½ªÎ»¤¹¤ë¤Î¤òÂԤĤ³¤È¤¬¤Ç¤¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£
871 ¤½¤·¤Æ¾Íè¤Ï¤³¤ì¤¬¥Ç¥Õ¥©¥ë¥È¤ÎÆ°ºî¤Ë¤Ê¤ë¤Ç¤¢¤í¤¦¡£
873 .\"O The following Linux-specific
875 .\"O are for use with children created using
878 ¤òÍѤ¤¤Æºî¤é¤ì¤¿»Ò¥×¥í¥»¥¹¤Ë¤Ï¡¢°Ê²¼¤Î Linux ¸ÇͤÎ
884 .\"O Wait for "clone" children only.
885 .\"O If omitted then wait
886 .\"O for "non-clone" children only.
887 .\"O (A "clone" child is one
888 .\"O which delivers no signal, or a signal other than
890 .\"O to its parent upon termination.)
891 "clone" ¤Ê»Ò¥×¥í¥»¥¹¤À¤±¤òÂԤġ£
892 »ØÄꤵ¤ì¤Ê¤«¤Ã¤¿¾ì¹ç¤ÏÈó "clone" ¤Ê»Ò¥×¥í¥»¥¹¤À¤±¤òÂÔ¤Ä
893 ("clone" ¤Ê»Ò¥×¥í¥»¥¹¤Ï¡¢½ªÎ»»þ¤Ë¿Æ¥×¥í¥»¥¹¤ØÁ´¤¯¥·¥°¥Ê¥ë¤òÁ÷¤é¤Ê¤¤¤«¡¢
895 °Ê³°¤Î¥·¥°¥Ê¥ë¤òÁ÷¤ë)¡£
896 .\"O This option is ignored if
898 .\"O is also specified.
901 ¤â»ØÄꤵ¤ì¤¿¾ì¹ç¤Ï̵»ë¤µ¤ì¤ë¡£
903 .\"O .BR __WALL " (since Linux 2.4)"
904 .BR __WALL " (Linux 2.4 °Ê¹ß)"
905 .\" since patch-2.3.48
906 .\"O Wait for all children, regardless of
907 .\"O type ("clone" or "non-clone").
908 "clone" ¤Ç¤¢¤ë¤«¤Ê¤¤¤«¤Ë´Ø¤ï¤é¤º¡¢
909 Á´¤Æ¤Î»Ò¥×¥í¥»¥¹¤òÂԤġ£
911 .\"O .BR __WNOTHREAD " (since Linux 2.4)"
912 .BR __WNOTHREAD " (Linux 2.4 °Ê¹ß)"
913 .\" since patch-2.4.0-test8
914 .\"O Do not wait for children of other threads in
915 .\"O the same thread group.
916 .\"O This was the default before Linux 2.4.
917 Ʊ¤¸¥¹¥ì¥Ã¥É¥°¥ë¡¼¥×¤Î¾¤Î¥¹¥ì¥Ã¥É¤Î»Ò¥×¥í¥»¥¹¤ÏÂÔ¤¿¤Ê¤¤¡£
918 Linux 2.4 ¤è¤êÁ°¤Ç¤Ï¥Ç¥Õ¥©¥ë¥È¤Ç¤¢¤Ã¤¿¡£
921 .\"O .\" fork.2 refers to this example program.
922 .\" fork.2 ¤â¤³¤Î¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤ò»²¾È¤·¤Æ¤¤¤ë¡£
923 .\"O The following program demonstrates the use of
927 .\"O The program creates a child process.
928 .\"O If no command-line argument is supplied to the program,
929 .\"O then the child suspends its execution using
931 .\"O to allow the user to send signals to the child.
932 .\"O Otherwise, if a command-line argument is supplied,
933 .\"O then the child exits immediately,
934 .\"O using the integer supplied on the command line as the exit status.
935 .\"O The parent process executes a loop that monitors the child using
937 .\"O and uses the W*() macros described above to analyze the wait status value.
942 ¤Î»ÈÍÑÊýË¡¤ÎÎã¤ò¼¨¤·¤Æ¤¤¤ë¡£
943 ¤³¤Î¥×¥í¥°¥é¥à¤Ç¤Ï»Ò¥×¥í¥»¥¹¤òÀ¸À®¤¹¤ë¡£
944 ¥³¥Þ¥ó¥É¥é¥¤¥ó°ú¤¿ô¤¬»ØÄꤵ¤ì¤Ê¤«¤Ã¤¿¤È¤¤Ï¡¢
947 ¤ò»È¤Ã¤Æ¤½¤Î¼Â¹Ô¤ò°ì»þÄä»ß¤·¡¢¥æ¡¼¥¶¤¬¤½¤Î»Ò¥×¥í¥»¥¹¤Ë
948 ¥·¥°¥Ê¥ë¤òÁ÷¿®¤Ç¤¤ë¤è¤¦¤Ë¤¹¤ë¡£
949 ¥³¥Þ¥ó¥É¥é¥¤¥ó°ú¤¿ô¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¤Ï¡¢
950 »Ò¥×¥í¥»¥¹¤Ïľ¤Á¤Ë½ªÎ»¤·¡¢
951 ¥³¥Þ¥ó¥É¥é¥¤¥ó¤Ç»ØÄꤵ¤ì¤¿À°¿ô¤ò½ªÎ»¥¹¥Æ¡¼¥¿¥¹¤È¤·¤Æ»ÈÍѤ¹¤ë¡£
954 ¤ò»È¤Ã¤Æ»Ò¥×¥í¥»¥¹¤ò´Æ»ë¤·¡¢
955 wait ¤Î¥¹¥Æ¡¼¥¿¥¹Ãͤò¾åµ¤Î W*() ¥Þ¥¯¥í¤ò»È¤Ã¤Æ²òÀϤ¹¤ë¤È¤¤¤¦
958 .\"O The following shell session demonstrates the use of the program:
959 ²¼µ¤Î¤Î¥·¥§¥ë¡¦¥»¥Ã¥·¥ç¥ó¤Ï¥×¥í¥°¥é¥à¤Î¼Â¹ÔÎã¤Ç¤¢¤ë:
966 .RB "$" " kill \-STOP 32360"
968 .RB "$" " kill \-CONT 32360"
970 .RB "$" " kill \-TERM 32360"
976 .\"O .SS Program source
977 .SS ¥×¥í¥°¥é¥à¤Î¥½¡¼¥¹
980 #include <sys/wait.h>
986 main(int argc, char *argv[])
997 if (cpid == 0) { /* Code executed by child */
998 printf("Child PID is %ld\\n", (long) getpid());
1000 pause(); /* Wait for signals */
1001 _exit(atoi(argv[1]));
1003 } else { /* Code executed by parent */
1005 w = waitpid(cpid, &status, WUNTRACED | WCONTINUED);
1011 if (WIFEXITED(status)) {
1012 printf("exited, status=%d\\n", WEXITSTATUS(status));
1013 } else if (WIFSIGNALED(status)) {
1014 printf("killed by signal %d\\n", WTERMSIG(status));
1015 } else if (WIFSTOPPED(status)) {
1016 printf("stopped by signal %d\\n", WSTOPSIG(status));
1017 } else if (WIFCONTINUED(status)) {
1018 printf("continued\\n");
1020 } while (!WIFEXITED(status) && !WIFSIGNALED(status));
1035 .BR pthread_create (3),
1036 .BR credentials (7),