.\" Copyright (c) 1980, 1991, 1993, 1994 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#) wait. 2 8.2 (Berkeley) 4/19/94 .\" .\" %FreeBSD: src/lib/libc/sys/wait. 2, v 1.6. 2.6 2001/12/14 18:34:02 ru Exp % .\" $FreeBSD: doc/ja_JP.eucJP/man/man2/wait. 2, v 1.7 2001/12/23 00:03:42 horikawa Exp $ .Dd April 19, 1994 .Dt WAIT 2 .Os .Sh ¸íĪ .Nm wait , .Nm waitpid , .Nm wait4 , .Nm wait3 .Nd ÇÁ·Î¼¼½ºÀÇ Á¾·á ´ë±â .Sh ÇÁ·Î±×·¥ ¶óÀ̺귯¸® .Lb libc .Sh ¼­½Ä .In sys/types.h .In sys/wait.h .Ft pid_t .Fn wait "int *status" .In sys/time.h .In sys/resource.h .Ft pid_t .Fn waitpid "pid_t wpid" "int *status" "int options" .Ft pid_t .Fn wait3 "int *status" "int options" "struct rusage *rusage" .Ft pid_t .Fn wait4 "pid_t wpid" "int *status" "int options" "struct rusage *rusage" .Sh ÇØ¼³ .Fn wait ÇÔ¼ö´Â, Á¾·áÇÑ child processÀÇ .Fa status Á¤º¸¸¦ »ç¿ëÇÒ ¼ö ÀÖ°Ô µÉ ¶§±îÁö, ¶Ç´Â ½Ã±×³ÎÀ» ¼ö½ÅÇÒ ¶§±îÁö, ¼Òȯ ÇÁ·Î¼¼½ºÀÇ ½ÇÇàÀ» Á¤ÁöÇÕ´Ï´Ù. .Fn wait ¼ÒȯÀÌ ¼º°øÇϸé(ÀÚ), .Fa status area¿¡´Â ¾Æ·¡ÀÇ Á¤ÀÇ¿Í °°ÀÌ Á¾·áÇÑ ÇÁ·Î¼¼½ºÀÇ Á¾·á Á¤º¸°¡ µé¾î°©´Ï´Ù. .Pp .Fn wait4 ¼ÒȯÀº, ƯÁ¤ÀÇ child process¸¦ ±â´Ù¸± Çʿ䰡 ÀÖ¾î, child process°¡ ÃàÀûÇÑ ¸®¼Ò½º ÀÌ¿ë Åë°è ȤÀº ¿É¼ÇÀ» ÇÊ¿ä·Î ÇÏ´Â ÇÁ·Î±×·¥À» À§Çؼ­(¶§¹®¿¡), º¸´Ù ÀϹÝÀûÀÎ ÀÎÅÍÆäÀ̽º¸¦ Á¦°øÇÕ´Ï´Ù. ±× ¿ÜÀÇ ´ë±â ÇÔ¼ö´Â, .Fn wait4 (À»)¸¦ »ç¿ëÇØ ½ÇÀåµÇ°í ÀÖ½À´Ï´Ù. .Pp .Fa wpid ÆÄ¶ó¹ÌÅÍ´Â ±â´Ù·Á¾ß ÇÒ child processÀÇ ÁýÇÕÀ» ÁöÁ¤ÇÕ´Ï´Ù. .Fa wpid ÇÏÁö¸¸ -1 ÀÎ °æ¿ì, ÀÌ ¼ÒȯÀº ¸ðµç child process¸¦ ±â´Ù¸³´Ï´Ù. .Fa wpid ÇÏÁö¸¸ 0 ÀÎ °æ¿ì, ÀÌ ¼ÒȯÀº, ¼ÒÈ¯ÃøÀÇ ÇÁ·Î¼¼½º ±×·ìÀÇ ¸ðµç child process¸¦ ±â´Ù¸³´Ï´Ù. .Fa wpid ÇÏÁö¸¸ 0 º¸´Ù Å« °æ¿ì, ÀÌ ¼ÒȯÀº ÇÁ·Î¼¼½º ID °¡ .Fa wpid ÀÎ ÇÁ·Î¼¼½º¸¦ ±â´Ù¸³´Ï´Ù. .Fa wpid ÇÏÁö¸¸ -1 º¸´Ù ÀÛÀº °æ¿ì, ¼ÒȯÀº, ÇÁ·Î¼¼½º ±×·ì ID °¡ .Fa wpid ÀÇ Àý´ëÄ¡¿¡ µ¿ÀÏÇÑ ÇÁ·Î¼¼½º¸¦ ±â´Ù¸³´Ï´Ù. .Pp .Fa status ÆÄ¶ó¹ÌÅÍ´Â, ÀÌÇÏ¿Í °°ÀÌ Á¤Àǵǰí ÀÖ½À´Ï´Ù. .Fa options ÆÄ¶ó¹ÌÅÍ¿¡´Â, ÀÌÇÏÀÇ ÀÓÀÇÀÇ ¿É¼ÇÀÇ ºñÆ® ³í¸®ÇÕÀÌ µé¾î°©´Ï´Ù. .Dv WNOHANG ¿É¼ÇÀº, ½ºÅ×ÀÌÅͽº¸¦ º¸°íÇÏ´Â ÇÁ·Î¼¼½º°¡ ¾ø´Â °æ¿ì¿¡ ¼ÒȯÀÌ ºí·Ï ÇÏÁö ¾Ê´Â °ÍÀ» ³ªÅ¸³»±â À§Çؼ­(¶§¹®¿¡) »ç¿ëÇÕ´Ï´Ù. .Dv WUNTRACED ¿É¼ÇÀ» ¼³Á¤Çϸé(ÀÚ), SIGTTIN ½Ã±×³Î, SIGTTOU ½Ã±×³Î, SIGTSTP ½Ã±×³Î, .Dv SIGSTOP ½Ã±×³ÎÀ» À§Çؼ­(¶§¹®¿¡) Á¤ÁöÇÑ °æÇâ ÇÁ·Î¼¼½ºÀÇ ¾ÆÀÌ¿¡°Ôµµ, ±× ½ºÅ×ÀÌÅͽº¸¦ º¸°í½Ãŵ´Ï´Ù. .Fa rusage ÇÏÁö¸¸ 0 ÀÌ¿ÜÀÎ °æ¿ì´Â, Á¾·áÇÑ ÇÁ·Î¼¼½º¿Í ±× ¸ðµç ¾ÆÀ̰¡ »ç¿ëÇÑ ¸®¼Ò½ºÀÇ ¿ä¾àÀÌ µ¹·ÁÁÖ¾îÁý´Ï´Ù (ÇöÀç·Î¼­´Â, ÀÌ Á¤º¸´Â Á¤ÁöÇÑ ÇÁ·Î¼¼½º¿¡ ´ëÇØ¼­´Â »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù). .Dv WNOHANG ¿É¼ÇÀ» ÁöÁ¤ÀÌ ÁöÁ¤µÇ¾î ½ºÅ×ÀÌÅͽº¸¦ º¸°íÇÏ´Â ÇÁ·Î¼¼½º°¡ ¾ø´Â °æ¿ì, .Fn wait4 (Àº)´Â ÇÁ·Î¼¼½º ID 0 À» µÇµ¹¸³´Ï´Ù. .Pp .Fn waitpid ¼ÒȯÀº, .Fa rusage ÀÇ °ªÀ» 0 À¸·Î Çß´Ù .Fn wait4 (¿Í)°ú °°½À´Ï´Ù. ³°´Ù .Fn wait3 ¼ÒȯÀº, .Fa wpid ÀÇ °ªÀ» -1 ·Î Çß´Ù .Fn wait4 (¿Í)°ú °°½À´Ï´Ù. .Pp ÀÌÇÏÀÇ ¸ÅÅ©·Î´Â, ÇÁ·Î¼¼½ºÀÇ Á¾·áÀÇ ¹æ¹ýÀ» ¾Æ´Âµ¥ »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù. ÃÖÃÊÀÇ 3 °³ÀÇ ¸ÅÅ©·Î´Â, 0 ÀÌ¿Ü (Áø)ÀÇ °ªÀ» Æò°¡ÇÕ´Ï´Ù. .Bl -tag -width Ds .It Fn WIFEXITED status .Xr _exit 2 Àΰ¡ .Xr exit 3 (À»)¸¦ ¼Òȯ, ÇÁ·Î¼¼½º°¡ Á¤»óÀûÀ¸·Î Á¾·áÇßÀ» °æ¿ì¿¡ ÁøÀÌ µË´Ï´Ù. .It Fn WIFSIGNALED status ½Ã±×³ÎÀ» ¼ö½ÅÇ߱⠶§¹®¿¡ ÇÁ·Î¼¼½º°¡ Á¾·áÇßÀ» °æ¿ì¿¡ ÁøÀÌ µË´Ï´Ù. .It Fn WIFSTOPPED status ÇÁ·Î¼¼½º°¡ Á¾·áÇϰí ÀÖÁö ¾ÊÁö¸¸, Á¤ÁöÇϰí ÀÖ¾î Àç°³ÇÒ ¼ö ÀÖ´Â °æ¿ì¿¡ Áø°ú µË´Ï´Ù. ÀÌ ¸ÅÅ©·Î´Â .Fn wait ¼ÒȯÀ¸·Î .Dv WUNTRACED ¿É¼ÇÀ» ÁöÁ¤ÇÏ´ÂÁö, child process°¡ Æ®·¹À̽º µÇ°í ÀÖ´Ù ( .Xr ptrace 2 (À»)¸¦ ÂüÁ¶) °æ¿ì¿¡¸¸ ÁøÀÌ µË´Ï´Ù. .El .Pp »ó±â ¸ÅÅ©·ÎÀÇ °ª¿¡ µû¶ó, ÀÌÇÏÀÇ ¸ÅÅ©·Î´Â, child processÀÇ ³ª¸ÓÁöÀÇ ½ºÅ×ÀÌÅͽº Á¤º¸¸¦ »ý¼ºÇÕ´Ï´Ù. .Bl -tag -width Ds .It Fn WEXITSTATUS status .Fn WIFEXITED status ÇÏÁö¸¸ ÁøÀÎ °æ¿ì¿¡, ¾ÆÀ̰¡ .Xr _exit 2 Àΰ¡ .Xr exit 3 ¿¡ °Ç³×ÁØ ÀμöÀÇ ÇÏÀ§ 8 ºñÆ®¸¦ Æò°¡ÇÕ´Ï´Ù. .It Fn WTERMSIG status .Fn WIFSIGNALED status ÇÏÁö¸¸ ÁøÀÎ °æ¿ì¿¡, ÇÁ·Î¼¼½ºÀÇ Á¾·áÀÇ ¿øÀÎÀÌ µÈ ½Ã±×³ÎÀÇ ¹øÈ£¸¦ Æò°¡ÇÕ´Ï´Ù. .It Fn WCOREDUMP status .Fn WIFSIGNALED status ÇÏÁö¸¸ ÁøÀÎ °æ¿ì¿¡, ÇÁ·Î¼¼½º°¡ Á¾·áÇÑ ´ÙÀ½¿¡, ½Ã±×³ÎÀ» ¼ö½ÅÇßÀ» ¶§ÀÇ ÇÁ·Î¼¼½ºÀÇ À̹ÌÁö¸¦ Æ÷ÇÔÇÑ ÄÚ¾î ÆÄÀÏÀÌ ÀÛ¼ºµÇ¾úÀ» °æ¿ì¿¡ ÁøÀÌ µË´Ï´Ù. .It Fn WSTOPSIG status .Fn WIFSTOPPED status ÇÏÁö¸¸ ÁøÀÎ °æ¿ì¿¡, ÇÁ·Î¼¼½ºÀÇ Á¤ÁöÀÇ ¿øÀÎÀÌ µÈ ½Ã±×³ÎÀÇ ¹øÈ£¸¦ Æò°¡ÇÕ´Ï´Ù. .El .Sh ÁÖ Á¾·á ½Ã±×³ÎÀÇ ¸®½ºÆ®¿¡ ´ëÇØ¼­´Â, .Xr sigaction 2 (À»)¸¦ ÂüÁ¶ÇØ ÁÖ¼¼¿ä. ½ºÅ×ÀÌÅͽº°¡ 0 ÀÌ´Ù°í ÇÏ´Â °ÍÀº, Á¤»óÀûÀ¸·Î Á¾·áÇß´Ù°í ÇÏ´Â °ÍÀÔ´Ï´Ù. .Pp ¸ðµç child processÀÇ Á¾·á¸¦ ±â´Ù¸®Áö ¾Ê°í parent process°¡ Á¾·áÇϸé(ÀÚ), ³ª¸ÓÁöÀÇ child process¿¡´Â parent process 1 ID (init ÀÇ ÇÁ·Î¼¼½º ID)¸¦ ÇÒ´çÇÒ ¼ö ÀÖ½À´Ï´Ù. .Pp ÀÓÀÇÀÇ .Fn wait ¼ÒȯÀÌ º¸·ù°¡ µÇ¾î ÀÖ´Â µ¿¾È¿¡ ½Ã±×³ÎÀ» ¼ö½ÅÇϸé(ÀÚ), ½Ã±×³Î ¼ö½Å routine°¡ µ¹¾Æ¿ÔÀ» ¶§¿¡, ¼ÒȯÀº ³¢¾îµé¾îÁú±î Àç°³µË´Ï´Ù. À̰ÍÀº ½Ã±×³Î¿¡ ¿µÇâÀ» ÁÖ´Â ¿É¼Ç¿¡ ÀÇÁ¸ÇÕ´Ï´Ù. .Xr intro 2 ½Ã½ºÅÛ ÄÝÀÇ Àç°³ (System call restart)ÀÇ Ç׸ñÀ» ÂüÁ¶ÇØ ÁÖ¼¼¿ä. .Sh ¹Ýȯ°ª child process°¡ Á¤ÁöÇß´ÂÁö Á¾·áÇ߱⠶§¹®¿¡ .Fn wait ÇÏÁö¸¸ µ¹¾Æ¿ÔÀ» °æ¿ì´Â, ¾ÆÀÌÀÇ ÇÁ·Î¼¼½º ID °¡ ¼ÒÈ¯Ãø ÇÁ·Î¼¼½º¿¡ µÇµ¹·ÁÁý´Ï´Ù. ±× ¿ÜÀÇ °æ¿ì´Â -1 ÀÌ µÇµ¹·ÁÁ® .Va errno ÇÏÁö¸¸ ¿¡·¯¸¦ ³ªÅ¸³»µµ·Ï(µíÀÌ) ¼³Á¤µË´Ï´Ù. .Pp child process°¡ Á¤ÁöÇϰí ÀÖ´ÂÁö Á¾·áÇ߱⠶§¹®¿¡ .Fn wait4 , .Fn wait3 , .Fn waitpid ÇÏÁö¸¸ µ¹¾Æ¿ÔÀ» °æ¿ì´Â, ¾ÆÀÌÀÇ ÇÁ·Î¼¼½º ID °¡ ¼ÒÈ¯Ãø ÇÁ·Î¼¼½º¿¡ µÇµ¹·ÁÁý´Ï´Ù. ¾ÆÁ÷ wait µÇ¾î ÀÖÁö ¾ÊÀº child process°¡ Á¸ÀçÇÏÁö ¾Ê´Â °æ¿ì´Â,-1 ÀÌ µÇµ¹·ÁÁ® .Va errno ÇÏÁö¸¸ .Er ECHILD (À¸)·Î ¼³Á¤µË´Ï´Ù. .Dv WNOHANG ÇÏÁö¸¸ ÁöÁ¤µÇ¾î Á¤ÁöÇÑ ¾ÆÀÌ ¶Ç´Â Á¾·áÇÑ ¾ÆÀ̰¡ ¾ø´Â °æ¿ì´Â 0 ÀÌ µÇµ¹·ÁÁý´Ï´Ù. ¿¡·¯°¡ °ËÃâµÇ´ÂÁö, ¼ö½Å ½Ã±×³Î¿¡ ÀÇÇØ ÀÌ ¼ÒȯÀÌ ÀÌ»óÁ¾·á(ABEND) ÇßÀ» °æ¿ì´Â, -1 ÇÏÁö¸¸ µÇµ¹·ÁÁ® .Va errno ÇÏÁö¸¸ ¿¡·¯¸¦ ³ªÅ¸³»µµ·Ï(µíÀÌ) ¼³Á¤µË´Ï´Ù. .Sh ¿¡·¯ .Fn wait (Àº)´Â ÀÌÇÏÀÇ °æ¿ì¿¡ ¿¡·¯°¡ µÇ¾î, Áï½Ã µ¹¾Æ¿É´Ï´Ù: .Bl -tag -width Er .It Bq Er ECHILD ¼ÒÈ¯Ãø ÇÁ·Î¼¼½º´Â, wait µÇ¾î ÀÖÁö ¾ÊÀº child process¸¦ °¡ÁöÁö ¾Ê½À´Ï´Ù. .It Bq Er EFAULT .Fa status ÀμöÀΰ¡ .Fa rusage Àμö°¡ À§¹ýÇÑ ÁÖ¼Ò¸¦ °¡¸®Å°°í ÀÖ½À´Ï´Ù. (child processÀÇ Á¾·áÀü¿¡´Â °ËÃâµÇÁö ¾Ê´Â °ÍÀÌ ÀÖ½À´Ï´Ù. ) .It Bq Er EINTR ¼ÒȯÀÌ ¼ö½Å ½Ã±×³Î¿¡ ÀÇÇØ ³¢¾îµé¾îÁ³´ÂÁö, ½Ã±×³Î¿¡ .Dv SA_RESTART Ç÷¡±×°¡ ¼³Á¤µÇ¾î ÀÖÁö ¾Ê½À´Ï´Ù. .El .Sh Ç¥ÁØ .Fn wait ÇÔ¼ö¿Í .Fn waitpid ÇÔ¼ö´Â POSIX ¿¡ ÀÇÇØ Á¤Àǵǰí ÀÖ½À´Ï´Ù. .Fn wait4 (¿Í)°ú .Fn wait3 (Àº)´Â POSIX ÀÇ »ç¾çÀÌ ¾Æ´Õ´Ï´Ù. .Fn WCOREDUMP ¸ÅÅ©·Î ¹× º¸·ùÁßÀÇ .Fn wait ¼ÒȯÀ» Àç°³ÇÏ´Â ±â´ÉÀº POSIX ÀÎÅÍÆäÀ̽ºÀÇ È®Àå ±â´ÉÀÔ´Ï´Ù. .Sh °ü·Ã Ç׸ñ .Xr ptrace 2 , .Xr sigaction 2 , .Xr _exit 2 , .Xr exit 3 .Sh ¿ª»ç .Fn wait ÇÔ¼ö´Â, .At v6 ±×¸®°í µîÀåÇß½À´Ï´Ù.