1 .\" Copyright (c) 1999 Andries Brouwer (aeb@cwi.nl), 1 Nov 1999
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 .\" 1999-11-10: Merged text taken from the page contributed by
24 .\" Reed H. Petty (rhp@draper.net)
26 .\" Japanese Version Copyright (c) 1999 HANATAKA Shinya
27 .\" all rights reserved.
28 .\" Translated 1999-12-04, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
29 .\" Updated 2007-01-09, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.43
30 .\" Updated 2008-11-10, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.13
32 .TH VFORK 2 2010-09-20 "Linux" "Linux Programmer's Manual"
34 vfork \- »Ò¥×¥í¥»¥¹¤òÀ¸À®¤·¿Æ¥×¥í¥»¥¹¤òÄä»ß¤µ¤»¤ë
36 .B #include <sys/types.h>
38 .B #include <unistd.h>
43 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
44 .RB ( feature_test_macros (7)
56 (_XOPEN_SOURCE\ >=\ 500 ||
57 _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED) &&
58 !(_POSIX_C_SOURCE\ >=\ 200809L || _XOPEN_SOURCE\ >=\ 700)
62 _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 ||
63 _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
75 ¤ÇºîÀ®¤µ¤ì¤¿¥×¥í¥»¥¹¤¬
77 ¤«¤é¤ÎÊÖ¤êÃͤò³ÊǼ¤·¤Æ¤¤¤ë
79 ·¿¤ÎÊÑ¿ô°Ê³°¤òÊѹ¹¤·¤¿¤ê¡¢
81 ¤ò¸Æ¤Ó½Ð¤·¤Æ¤¤¤ë´Ø¿ô¤«¤é return ¤·¤¿¤ê¡¢
85 ²¤Î´Ø¿ô¤ò¥³¡¼¥ë¤¹¤ëÁ°¤Ë¾¤Î´Ø¿ô¤ò¥³¡¼¥ë¤·¤¿¾ì¹ç¤ÎÆ°ºî¤¬
86 ̤ÄêµÁ¤Ç¤¢¤ë¤È¤¤¤¦ÅÀ¤¬°Û¤Ê¤ë¡£
91 ¤ÈÁ´¤¯Æ±¤¸¤è¤¦¤Ë¸Æ¤Ó½Ð¤·¤¿¥×¥í¥»¥¹¤Î»Ò¥×¥í¥»¥¹¤òÀ¸À®¤¹¤ë¡£
92 ¾Ü¤·¤¤ÀâÌÀ¤ÈÊÖ¤êÃÍ¡¢¥¨¥é¡¼¤Ë¤Ä¤¤¤Æ¤Ï
100 ¿Æ¥×¥í¥»¥¹¤Î¥Ú¡¼¥¸¥Æ¡¼¥Ö¥ë¤Î¥³¥Ô¡¼¤ò¹Ô¤ï¤º¤Ë¿·¤·¤¤¥×¥í¥»¥¹¤ò
101 ºîÀ®¤¹¤ë¤¿¤á¤Ë»ÈÍѤ¹¤ë¡£¤³¤ì¤ÏÀǽ¤ËÉÒ´¶¤Ê¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ë¤ª¤¤¤Æ
102 »Ò¥×¥í¥»¥¹¤òÀ¸À®¤·¤Æ¤¹¤°¤Ë
104 ¤¹¤ë¾ì¹ç¤ËÍÍѤ«¤â¤·¤ì¤Ê¤¤¡£
109 ¤È°ã¤¤¡¢»Ò¥×¥í¥»¥¹¤¬½ªÎ»¤¹¤ë¤«¡¢
111 ¤ò¥³¡¼¥ë¤¹¤ë¤Þ¤Ç¿Æ¥×¥í¥»¥¹¤òÄä»ß (suspend) ¤µ¤»¤ë¡£
114 ¤Î¸Æ¤Ó½Ð¤·¤Ë¤è¤ëÄ̾ェλ¡¢
115 Ã×̿Ū¤Ê¥·¥°¥Ê¥ë¤ÎÇÛÁ÷¸å¤Î°Û¾ï½ªÎ»¤ÎÆó¤Ä¤Î¥±¡¼¥¹¤¬¤¢¤ë¡£
116 ¤³¤Î»þÅÀ¤Þ¤Ç¤Ï¡¢»Ò¥×¥í¥»¥¹¤Ï¥¹¥¿¥Ã¥¯¤ò´Þ¤àÁ´¤Æ¤Î¥á¥â¥ê¤ò
117 ¿Æ¥×¥í¥»¥¹¤È¶¦Í¤¹¤ë¡£
118 »Ò¥×¥í¥»¥¹¤Ï¸½ºß¤Î´Ø¿ô¤«¤é return ¤·¤Æ¤Ï¤Ê¤é¤º¡¢
120 ¤â¥³¡¼¥ë¤·¤Æ¤Ï¤Ê¤é¤Ê¤¤¤¬¡¢
122 ¤Ê¤é¤Ð¥³¡¼¥ë¤·¤Æ¤â¤è¤¤¡£
124 ¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤Ï·Ñ¾µ¤µ¤ì¤ë¤¬¡¢¶¦Í¤Ï¤µ¤ì¤Ê¤¤¡£
125 ¿Æ¥×¥í¥»¥¹¤Ø¤Î¥·¥°¥Ê¥ë¤Ï¡¢»Ò¥×¥í¥»¥¹¤¬¿Æ¥×¥í¥»¥¹¤Î¥á¥â¥ê¤ò
126 ²òÊü¤·¤¿¸å (¤¹¤Ê¤ï¤Á¡¢»Ò¥×¥í¥»¥¹¤¬½ªÎ»¤¹¤ë¤«
128 ¤ò¸Æ¤ó¤À¸å) ¤ËÅþÃ夹¤ë¡£
132 ¤Ï½ñ¤¹þ¤ß»þ¥³¥Ô¡¼ (copy-on-write) ¥Ú¡¼¥¸¤ò»ÈÍѤ·¤Æ¼ÂÁõ¤µ¤ì¤Æ¤¤¤ë¡£
135 ¤ò»ÈÍѤ¹¤ë¤³¤È¤Ë¤è¤Ã¤ÆÈï¤ë»³²¤Ï¿Æ¥×¥í¥»¥¹¤Î¥Ú¡¼¥¸¡¦¥Æ¡¼¥Ö¥ë¤ò
136 Ê£À½¤¹¤ë¤¿¤á¤ËɬÍפʻþ´Ö¤È¥á¥â¥ê¤À¤±¤Ç¤¢¤ë¡£
137 ¤·¤«¤·¤Ê¤¬¤é¡¢´÷¤·¤ÀΤˤÏ
139 ¤Ï¸Æ¤Ó½Ð¤·¤¿¥×¥í¥»¥¹¤Î¥Ç¡¼¥¿¶õ´Ö¤ÎÁ´¤Æ¤Î¥³¥Ô¡¼¤·¤Æ¤¤¤¿¤¬¡¢
140 ¤³¤ì¤Ï¤·¤Ð¤·¤ÐÉÔɬÍפǤ¢¤Ã¤¿¡£¤Ê¤¼¤Ê¤é¡¢¤¿¤¤¤Æ¤¤¤Ï¤¹¤°¸å¤Ë
142 ¤ò¼Â¹Ô¤·¤Æ¤¤¤¿¤«¤é¤Ç¤¢¤ë¡£
143 ¤³¤Î¾ì¹ç¤Î¸úΨ¤ò¾å¤²¤ë¤¿¤á¤Ë BSD ¤Ï
145 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤òƳÆþ¤·¤Æ¿Æ¥×¥í¥»¥¹¤Î¥¢¥É¥ì¥¹¶õ´Ö¤ò´°Á´¤Ë¥³¥Ô¡¼
148 ¤ò¥³¡¼¥ë¤¹¤ë¤« exit ¤¬µ¯¤¤ë¤Þ¤Ç¿Æ¥×¥í¥»¥¹¤Î¥á¥â¥ê¤ÈÀ©¸æ¥¹¥ì¥Ã¥É
150 ¿Æ¥×¥í¥»¥¹¤Ï»Ò¥×¥í¥»¥¹¤¬¤½¤Î»ñ¸»¤ò»ÈÍѤ·¤Æ¤¤¤ë´Ö¤ÏÄä»ß¤µ¤ì¤¿¡£
152 ¤Ï»È¤¤¤Ë¤¯¤¤¤â¤Î¤Ç¤¢¤Ã¤¿: Î㤨¤Ð¡¢¿Æ¥×¥í¥»¥¹¤ÎÊÑ¿ô¤òÊѹ¹¤·¤Ê
153 ¤¤¤è¤¦¤Ë¤¹¤ë¤¿¤á¤Ë¤Ï¤É¤ÎÊÑ¿ô¤¬¥ì¥¸¥¹¥¿¤ËÊÝ»ý¤µ¤ì¤Æ¤¤¤ë¤«¤òÃΤé¤Ê
156 4.3BSD, POSIX.1-2001.
159 ¤Îµ¬Ä꤬ºï½ü¤µ¤ì¤Æ¤¤¤ë¡£
161 ¥³¡¼¥ë¤Ï¾¤Î¥ª¥Ú¥ì¡¼¥Æ¥£¥ó¥°¡¦¥·¥¹¥Æ¥à¤ÎƱ̾¤Î¥³¡¼¥ë¤È
162 ¤Á¤ç¤Ã¤È»÷¤Æ¤¤¤ë¤«¤â¤·¤ì¤Ê¤¤¡£µ¬³Ê¤¬
164 ¤ËÍ׵ᤷ¤Æ¤¤¤ë¤³¤È¤Ï¡¢
166 ¤ËÍ׵ᤷ¤Æ¤¤¤ë¤³¤È¤è¤ê¤Ï¼å¤¤¡£¤·¤¿¤¬¤Ã¤Æ¡¢
167 ξ¼Ô¤òƱ¤¸¤â¤Î¤È¤·¤Æ¼ÂÁõ¤·¤Æ¤â¡¢µ¬³Ê¤Ë½àµò¤·¤Æ¤¤¤ë¤³¤È¤Ë¤Ê¤ë¡£
168 ÆÃ¤Ë¥×¥í¥°¥é¥Þ¡¼¤Ï¡¢»Ò¥×¥í¥»¥¹¤¬½ªÎ»¤¹¤ë¤«
170 ¤ò¸Æ¤Ó½Ð¤¹¤Þ¤Ç¿Æ¥×¥í¥»¥¹¤¬Ää»ß¤·¤Æ¤¤¤ë¤³¤È¤ä¡¢¥á¥â¥ê¤ò¶¦Í¤¹¤ë¤³
171 ¤È¤Ë¤è¤ëÆüì¤ÊÆ°ºî¤ò¤¢¤Æ¤Ë¤¹¤Ù¤¤Ç¤Ï¤Ê¤¤¡£
172 .\" In AIXv3.1 vfork is equivalent to fork.
175 .BR pthread_atfork (3)
176 ¤ò»È¤Ã¤ÆÀßÄꤵ¤ì¤¿ fork ¥Ï¥ó¥É¥é¤Ï
177 NPTL ¥¹¥ì¥Ã¥É¥é¥¤¥Ö¥é¥ê¥³¡¼¥ë¤òºÎÍѤ·¤¿¥Þ¥ë¥Á¥¹¥ì¥Ã¥É¥×¥í¥°¥é¥à¤Ç¤Ï
178 ¸Æ¤Ó½Ð¤µ¤ì¤Ê¤¤¡£°ìÊý¡¢LinuxThreads ¥¹¥ì¥Ã¥É¥é¥¤¥Ö¥é¥ê¤ò»È¤Ã¤¿
179 ¥×¥í¥°¥é¥à¤Ç¤Ï¡¢fork ¥Ï¥ó¥É¥é¤Ï¸Æ¤Ó½Ð¤µ¤ì¤ë¡£
180 (Linux ¤Î¥¹¥ì¥Ã¥É¥é¥¤¥Ö¥é¥ê¤ÎÀâÌÀ¤Ï
185 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï 3.0BSD ¤Ë¸½¤ï¤ì¤¿¡£
186 .\" In the release notes for 4.2BSD Sam Leffler wrote: `vfork: Is still
187 .\" present, but definitely on its way out'.
190 ¤ÎƱµÁ¸ì¤È¤Ê¤Ã¤¿¤¬¡¢NetBSD ¤Ç¤ÏºÆ¤ÓƳÆþ¤µ¤ì¤¿¡£
191 http://www.netbsd.org/Documentation/kernel/vfork.html ¤ò»²¾È¡£
192 Linux ¤Ç¤Ï 2.2.0-pre6 ¤¢¤¿¤ê¤Þ¤Ç¤Ï
194 ¤ÈÅù²Á¤Ç¤¢¤Ã¤¿¡£(i386 ¤Ç¤Ï) 2.2.0-pre9 ¤«¤é (¾¤Î¥¢¡¼¥¥Æ¥¯¥Á¥ã¤Ç¤Ï
195 ¾¯¤·ÃÙ¤ì¤Æ) ÆÈΩ¤·¤¿¥·¥¹¥Æ¥à¥³¡¼¥ë¤È¤Ê¤Ã¤¿¡£
196 glibc ¤Ç¤Î¥µ¥Ý¡¼¥È¤Ï glibc-2.0.112 ¤ÇÄɲ䵤줿¡£
198 Linux ¤¬¤³¤Î²áµî¤ÎË´Îî¤òÉü³è¤µ¤»¤¿¤³¤È¤Ï¡¢¤à¤·¤íÉÔ¹¬¤È¸À¤¦¤Ù¤¤Ç¤¢¤ë¡£
199 BSD ¤Î¥Þ¥Ë¥å¥¢¥ë¤Ë¤Ï¡¢
200 ¡Ö¤³¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤ÏÂÅÅö¤Ê¥·¥¹¥Æ¥à¶¦Íµ¡¹½¤¬¼ÂÁõ¤µ¤ì¤¿¾ì¹ç¤Ë¤Ï
203 ¤Î¥á¥â¥ê¶¦Íµ¡Ç½¤Ë°Í¸¤¹¤ë¤Ù¤¤Ç¤Ï¤Ê¤¤¡£²¿¸Î¤Ê¤é¤Ð¡¢¤³¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë
204 ¤¬ºï½ü¤µ¤ì¤¿¾ì¹ç¤Ë¤Ï¡¢¤½¤ì¤Ï
206 ¤ÎƱµÁ¸ì¤È¤µ¤ì¤ë¤«¤é¤Ç¤¢¤ë¡£¡×¤È½ñ¤«¤ì¤Æ¤¤¤ë¡£
208 ¥·¥°¥Ê¥ë¤Î°·¤¤¤Î¾ÜºÙ¤ÏÉÔÌÀÎƤǥ·¥¹¥Æ¥à¤´¤È¤Ë°Û¤Ã¤Æ¤¤¤ë¡£
209 BSD ¤Î¥Þ¥Ë¥å¥¢¥ë¤Ë¤Ï¡¢
210 ¡Ö¥Ç¥Ã¥É¥í¥Ã¥¯¾õÂ֤ˤʤë²ÄǽÀ¤¬¤¢¤ë¤Î¤Ç
216 ¥·¥°¥Ê¥ë¤òÁ÷¿®¤·¤Æ¤Ï¤Ê¤é¤Ê¤¤;
219 ¤Ïµö¤µ¤ì¤ë¤¬¡¢ÆþÎϤò»î¤ß¤¿¾ì¹ç¤Ë¤Ï·ë²Ì¤Ï¥Õ¥¡¥¤¥ë½ªÃ¼ (EOF) ¤Ë¤Ê¤ë¡£¡×
222 .\" As far as I can tell, the following is not true in 2.6.19:
223 .\" ¸½ºß¤Î¤È¤³¤í (Linux 2.3.25)¡¢
227 .\" ¤òÄÉÀפ¹¤ë¤³¤È¤¬¤Ç¤¤º¡¢¥«¡¼¥Í¥ë¥Ñ¥Ã¥Á¤¬É¬ÍפǤ¢¤ë¡£