OSDN Git Service

(split) LDP v3.30, v3.31 の定型的な変更内容を反映。
[linuxjm/LDP_man-pages.git] / draft / man2 / clone.2
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" Copyright (c) 1992 Drew Eckhardt <drew@cs.colorado.edu>, March 28, 1992
4 .\" and Copyright (c) Michael Kerrisk, 2001, 2002, 2005
5 .\" May be distributed under the GNU General Public License.
6 .\" Modified by Michael Haardt <michael@moria.de>
7 .\" Modified 24 Jul 1993 by Rik Faith <faith@cs.unc.edu>
8 .\" Modified 21 Aug 1994 by Michael Chastain <mec@shell.portal.com>:
9 .\"   New man page (copied from 'fork.2').
10 .\" Modified 10 June 1995 by Andries Brouwer <aeb@cwi.nl>
11 .\" Modified 25 April 1998 by Xavier Leroy <Xavier.Leroy@inria.fr>
12 .\" Modified 26 Jun 2001 by Michael Kerrisk
13 .\"     Mostly upgraded to 2.4.x
14 .\"     Added prototype for sys_clone() plus description
15 .\"     Added CLONE_THREAD with a brief description of thread groups
16 .\"     Added CLONE_PARENT and revised entire page remove ambiguity
17 .\"             between "calling process" and "parent process"
18 .\"     Added CLONE_PTRACE and CLONE_VFORK
19 .\"     Added EPERM and EINVAL error codes
20 .\"     Renamed "__clone" to "clone" (which is the prototype in <sched.h>)
21 .\"     various other minor tidy ups and clarifications.
22 .\" Modified 26 Jun 2001 by Michael Kerrisk <mtk.manpages@gmail.com>
23 .\"     Updated notes for 2.4.7+ behavior of CLONE_THREAD
24 .\" Modified 15 Oct 2002 by Michael Kerrisk <mtk.manpages@gmail.com>
25 .\"     Added description for CLONE_NEWNS, which was added in 2.4.19
26 .\" Slightly rephrased, aeb.
27 .\" Modified 1 Feb 2003 - added CLONE_SIGHAND restriction, aeb.
28 .\" Modified 1 Jan 2004 - various updates, aeb
29 .\" Modified 2004-09-10 - added CLONE_PARENT_SETTID etc. - aeb.
30 .\" 2005-04-12, mtk, noted the PID caching behavior of NPTL's getpid()
31 .\"     wrapper under BUGS.
32 .\" 2005-05-10, mtk, added CLONE_SYSVSEM, CLONE_UNTRACED, CLONE_STOPPED.
33 .\" 2005-05-17, mtk, Substantially enhanced discussion of CLONE_THREAD.
34 .\" 2008-11-18, mtk, order CLONE_* flags  alphabetically
35 .\" 2008-11-18, mtk, document CLONE_NEWPID
36 .\" 2008-11-19, mtk, document CLONE_NEWUTS
37 .\" 2008-11-19, mtk, document CLONE_NEWIPC
38 .\" 2008-11-19, Jens Axboe, mtk, document CLONE_IO
39 .\"
40 .\" FIXME Document CLONE_NEWUSER, which is new in 2.6.23
41 .\"       (also supported for unshare()?)
42 .\" FIXME . 2.6.25 marks the unused CLONE_STOPPED as obsolete, and it will
43 .\"       probably be removed in the future.
44 .\"
45 .\" Japanese Version Copyright (c) 2001 HANATAKA Shinya
46 .\"     and Copyright(c) 2002, 2005-2008 Akihiro MOTOKI
47 .\" Translated 2001-08-17, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
48 .\" Modified 2002-09-24, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
49 .\" Modified 2005-02-02, Akihiro MOTOKI
50 .\" Updated 2005-04-17, Akihiro MOTOKI
51 .\" Updated 2005-09-10, Akihiro MOTOKI
52 .\" Updated 2006-03-05, Akihiro MOTOKI, LDP v2.25
53 .\" Updated 2007-01-05, Akihiro MOTOKI, LDP v2.43
54 .\" Updated 2007-05-01, Akihiro MOTOKI, LDP v2.46
55 .\" Updated 2007-06-13, Akihiro MOTOKI, LDP v2.55
56 .\" Updated 2008-08-04, Akihiro MOTOKI, LDP v3.05
57 .\" Updated 2008-11-09, Akihiro MOTOKI, LDP v3.10
58 .\" Updated 2009-03-02, Akihiro MOTOKI, LDP v3.19
59 .\" Updated 2010-04-11, Akihiro MOTOKI, LDP v3.24
60 .\"
61 .\"WORD:        capability      ¥±¡¼¥Ñ¥Ó¥ê¥Æ¥£
62 .\"WORD:        pending signals ½èÍýÂÔ¤Á¥·¥°¥Ê¥ë
63 .\"WORD:        namespace       Ì¾Á°¶õ´Ö
64 .\"
65 .TH CLONE 2 2010-11-01 "Linux" "Linux Programmer's Manual"
66 .\"O .SH NAME
67 .\"O clone, __clone2 \- create a child process
68 .SH Ì¾Á°
69 clone, __clone2 \- »Ò¥×¥í¥»¥¹¤òºîÀ®¤¹¤ë
70 .\"O .SH SYNOPSIS
71 .SH ½ñ¼°
72 .nf
73 .\"O .BR "#define _GNU_SOURCE" "             /* See feature_test_macros(7) */"
74 .BR "#define _GNU_SOURCE" "             /* feature_test_macros(7) »²¾È */"
75 .\" Actually _BSD_SOURCE || _SVID_SOURCE
76 .\" See http://sources.redhat.com/bugzilla/show_bug.cgi?id=4749
77 .B #include <sched.h>
78
79 .BI "int clone(int (*" "fn" ")(void *), void *" child_stack ,
80 .BI "          int " flags ", void *" "arg" ", ... "
81 .BI "          /* pid_t *" ptid ", struct user_desc *" tls \
82 ", pid_t *" ctid " */ );"
83 .fi
84 .\"O .SH DESCRIPTION
85 .SH ÀâÌÀ
86 .\"O .BR clone ()
87 .\"O creates a new process, in a manner similar to
88 .\"O .BR fork (2).
89 .\"O It is actually a library function layered on top of the underlying
90 .\"O .BR clone ()
91 .\"O system call, hereinafter referred to as
92 .\"O .BR sys_clone .
93 .\"O A description of
94 .\"O .B sys_clone
95 .\"O is given toward the end of this page.
96 .BR clone ()
97 ¤Ï
98 .BR fork (2)
99 ¤ÈƱ¤¸¤è¤¦¤ÊÊýË¡¤Ç¿·¤·¤¤¥×¥í¥»¥¹¤òºîÀ®¤¹¤ë¡£
100 .BR clone ()
101 ¤Ë¤Ï¡¢¥é¥¤¥Ö¥é¥ê´Ø¿ô¤È¤½¤Î²¼Áؤˤ¢¤¿¤ë
102 .BR clone ()
103 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤¬Â¸ºß¤¹¤ë¡£°Ê²¼¤ÎÀâÌÀ¤Ç¤Ï¡¢¥·¥¹¥Æ¥à¥³¡¼¥ë¤ÎÊý¤ò
104 .B sys_clone
105 ¤Èɽ¤¹¤³¤È¤È¤¹¤ë¡£
106 .B sys_clone
107 ¤Ë´Ø¤¹¤ëÀâÌÀ¤Ï¤³¤Î¥Þ¥Ë¥å¥¢¥ë¤ÎºÇ¸å¤ÎÊý¤Ë¤¢¤ë¡£
108
109 .\"O Unlike
110 .\"O .BR fork (2),
111 .\"O these calls
112 .\"O allow the child process to share parts of its execution context with
113 .\"O the calling process, such as the memory space, the table of file
114 .\"O descriptors, and the table of signal handlers.
115 .\"O (Note that on this manual
116 .\"O page, "calling process" normally corresponds to "parent process".
117 .\"O But see the description of
118 .\"O .B CLONE_PARENT
119 .\"O below.)
120 .BR fork (2)
121 ¤È¤Ï°Û¤Ê¤ê¡¢¤³¤ì¤é¤Î¥³¡¼¥ë¤Ç¤Ï¡¢»Ò¥×¥í¥»¥¹ (child process)
122 ¤È¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤È¤¬¡¢¥á¥â¥ê¶õ´Ö¡¢
123 ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Î¥Æ¡¼¥Ö¥ë¡¢¥·¥°¥Ê¥ë¡¦¥Ï¥ó¥É¥é¤Î¥Æ¡¼¥Ö¥ë¤Ê¤É¤Î
124 ¼Â¹Ô¥³¥ó¥Æ¥­¥¹¥È¤Î°ìÉô¤ò¶¦Í­¤Ç¤­¤ë¡£
125 (¤³¤Î¥Þ¥Ë¥å¥¢¥ë¤Ë¤ª¤±¤ë¡Ö¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¡×¤Ï¡¢Ä̾ï¤Ï
126 ¡Ö¿Æ¥×¥í¥»¥¹¡×¤È°ìÃפ¹¤ë¡£Ã¢¤·¡¢¸å½Ò¤Î
127 .B CLONE_PARENT
128 ¤Î¹à¤â»²¾È¤Î¤³¤È)
129
130 .\"O The main use of
131 .\"O .BR clone ()
132 .\"O is to implement threads: multiple threads of control in a program that
133 .\"O run concurrently in a shared memory space.
134 .BR clone ()
135 ¤Î¼çÍפʻÈÍÑË¡¤Ï¥¹¥ì¥Ã¥É (threads) ¤ò¼ÂÁõ¤¹¤ë¤³¤È¤Ç¤¢¤ë:
136 °ì¤Ä¤Î¥×¥í¥°¥é¥à¤ÎÃæ¤ÎÊ£¿ô¤Î¥¹¥ì¥Ã¥É¤Ï¶¦Í­¤µ¤ì¤¿¥á¥â¥ê¶õ´Ö¤Ç
137 Ʊ»þ¤Ë¼Â¹Ô¤µ¤ì¤ë¡£
138
139 .\"O When the child process is created with
140 .\"O .BR clone (),
141 .\"O it executes the function
142 .\"O application
143 .\"O .IR fn ( arg ).
144 .\"O (This differs from
145 .\"O .BR fork (2),
146 .\"O where execution continues in the child from the point
147 .\"O of the
148 .\"O .BR fork (2)
149 .\"O call.)
150 .\"O The
151 .\"O .I fn
152 .\"O argument is a pointer to a function that is called by the child
153 .\"O process at the beginning of its execution.
154 .\"O The
155 .\"O .I arg
156 .\"O argument is passed to the
157 .\"O .I fn
158 .\"O function.
159 .BR clone ()
160 ¤Ç»Ò¥×¥í¥»¥¹¤¬ºîÀ®¤µ¤ì¤¿»þ¤Ë¡¢ºîÀ®¤µ¤ì¤¿»Ò¥×¥í¥»¥¹¤Ï´Ø¿ô
161 .IR fn ( arg )
162 ¤ò¼Â¹Ô¤¹¤ë¡£
163 (¤³¤ÎÅÀ¤¬
164 .BR fork (2)
165 ¤È¤Ï°Û¤Ê¤ë¡£
166 .BR fork (2)
167 ¤Î¾ì¹ç¡¢»Ò¥×¥í¥»¥¹¤Ï
168 .BR fork (2)
169 ¤¬¸Æ¤Ó½Ð¤µ¤ì¤¿¾ì½ê¤«¤é¼Â¹Ô¤ò³¤±¤ë¡£)
170 .I fn
171 °ú¤­¿ô¤Ï¡¢»Ò¥×¥í¥»¥¹¤¬¼Â¹Ô¤ò»Ï¤á¤ë»þ¤Ë»Ò¥×¥í¥»¥¹¤¬¸Æ¤Ó½Ð¤¹
172 ´Ø¿ô¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£
173 .I arg
174 °ú¤­¿ô¤Ï¤½¤Î¤Þ¤Þ
175 .I fn
176 ´Ø¿ô¤Ø¤ÈÅϤµ¤ì¤ë¡£
177
178 .\"O When the
179 .\"O .IR fn ( arg )
180 .\"O function application returns, the child process terminates.
181 .\"O The integer returned by
182 .\"O .I fn
183 .\"O is the exit code for the child process.
184 .\"O The child process may also terminate explicitly by calling
185 .\"O .BR exit (2)
186 .\"O or after receiving a fatal signal.
187 .IR fn ( arg )
188 ´Ø¿ô¤¬½ªÎ»¤¹¤ë¤È¡¢»Ò¥×¥í¥»¥¹¤Ï½ªÎ»¤¹¤ë¡£
189 .I fn
190 ¤Ë¤è¤Ã¤ÆÊÖ¤µ¤ì¤¿À°¿ô¤¬»Ò¥×¥í¥»¥¹¤Î½ªÎ»¥³¡¼¥É¤È¤Ê¤ë¡£
191 »Ò¥×¥í¥»¥¹¤Ï¡¢
192 .BR exit (2)
193 ¤ò¸Æ¤ó¤ÇÌÀ¼¨Åª¤Ë½ªÎ»¤¹¤ë¤³¤È¤â¤¢¤ë¤·¡¢Ã×̿Ū¤Ê¥·¥°¥Ê¥ë¤ò¼õ¿®¤·¤¿
194 ¾ì¹ç¤Ë½ªÎ»¤¹¤ë¤³¤È¤â¤¢¤ë¡£
195
196 .\"O The
197 .\"O .I child_stack
198 .\"O argument specifies the location of the stack used by the child process.
199 .\"O Since the child and calling process may share memory,
200 .\"O it is not possible for the child process to execute in the
201 .\"O same stack as the calling process.
202 .\"O The calling process must therefore
203 .\"O set up memory space for the child stack and pass a pointer to this
204 .\"O space to
205 .\"O .BR clone ().
206 .I child_stack
207 °ú¤­¿ô¤Ï¡¢»Ò¥×¥í¥»¥¹¤Ë¤è¤Ã¤Æ»ÈÍѤµ¤ì¤ë¥¹¥¿¥Ã¥¯¤Î°ÌÃÖ¤ò»ØÄꤹ¤ë¡£
208 »Ò¥×¥í¥»¥¹¤È¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Ï¥á¥â¥ê¤ò¶¦Í­¤¹¤ë¤³¤È¤¬¤¢¤ë¤¿¤á¡¢
209 »Ò¥×¥í¥»¥¹¤Ï¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ÈƱ¤¸¥¹¥¿¥Ã¥¯¤Ç¼Â¹Ô¤¹¤ë¤³¤È¤¬¤Ç¤­¤Ê¤¤¡£
210 ¤³¤Î¤¿¤á¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Ï»Ò¥×¥í¥»¥¹¤Î¥¹¥¿¥Ã¥¯¤Î¤¿¤á¤Î¥á¥â¥ê¶õ´Ö¤ò
211 ÍÑ°Õ¤·¤Æ¡¢¤³¤Î¶õ´Ö¤Ø¤Î¥Ý¥¤¥ó¥¿¤ò
212 .BR clone ()
213 ¤ØÅϤµ¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
214 .\"O Stacks grow downward on all processors that run Linux
215 .\"O (except the HP PA processors), so
216 .\"O .I child_stack
217 .\"O usually points to the topmost address of the memory space set up for
218 .\"O the child stack.
219 (HP PA ¥×¥í¥»¥Ã¥µ°Ê³°¤Î) Linux ¤¬Æ°ºî¤¹¤ëÁ´¤Æ¤Î¥×¥í¥»¥Ã¥µ¤Ç¤Ï¡¢
220 ¥¹¥¿¥Ã¥¯¤Ï²¼Êý (¥¢¥É¥ì¥¹¤¬¾®¤µ¤¤Êý¸þ) ¤Ø¤È¿­¤Ó¤ë¡£¤³¤Î¤¿¤á¡¢ÉáÄ̤Ï
221 .I child_stack
222 ¤Ï»Ò¥×¥í¥»¥¹¤Î¥¹¥¿¥Ã¥¯¤Î¤¿¤á¤ËÍÑ°Õ¤·¤¿¥á¥â¥ê¶õ´Ö¤Î°ìÈÖÂ礭¤¤
223 ¥¢¥É¥ì¥¹¤ò»Ø¤¹¤è¤¦¤Ë¤¹¤ë¡£
224
225 .\"O The low byte of
226 .\"O .I flags
227 .\"O contains the number of the
228 .\"O .I "termination signal"
229 .\"O sent to the parent when the child dies.
230 .\"O If this signal is specified as anything other than
231 .\"O .BR SIGCHLD ,
232 .\"O then the parent process must specify the
233 .\"O .B __WALL
234 .\"O or
235 .\"O .B __WCLONE
236 .\"O options when waiting for the child with
237 .\"O .BR wait (2).
238 .\"O If no signal is specified, then the parent process is not signaled
239 .\"O when the child terminates.
240 .I flags
241 ¤Î²¼°Ì 1 ¥Ð¥¤¥È¤Ï»Ò¥×¥í¥»¥¹¤¬»à¤ó¤À¾ì¹ç¤Ë¿Æ¥×¥í¥»¥¹¤Ø¤ÈÁ÷¤é¤ì¤ë
242 .I "½ªÎ»¥·¥°¥Ê¥ë (termination signal)"
243 ¤ÎÈÖ¹æ¤ò»ØÄꤹ¤ë¡£¤³¤Î¥·¥°¥Ê¥ë¤È¤·¤Æ
244 .B SIGCHLD
245 °Ê³°¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¡¢¿Æ¥×¥í¥»¥¹¤Ï¡¢
246 .BR wait (2)
247 ¤Ç»Ò¥×¥í¥»¥¹¤òÂԤĺݤˡ¢¥ª¥×¥·¥ç¥ó¤È¤·¤Æ
248 .B __WALL
249 ¤Þ¤¿¤Ï
250 .B __WCLONE
251 ¤ò»ØÄꤷ¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
252 ¤É¤Î¥·¥°¥Ê¥ë¤â»ØÄꤵ¤ì¤Ê¤«¤Ã¤¿¾ì¹ç¡¢»Ò¥×¥í¥»¥¹¤¬½ªÎ»¤·¤¿»þ¤Ë¿Æ¥×¥í¥»¥¹
253 ¤Ë¥·¥°¥Ê¥ë¤ÏÁ÷¤é¤ì¤Ê¤¤¡£
254
255 .\"O .I flags
256 .\"O may also be bitwise-or'ed with zero or more of the following constants,
257 .\"O in order to specify what is shared between the calling process
258 .\"O and the child process:
259 .I flags
260 ¤Ë¤Ï¡¢°Ê²¼¤ÎÄê¿ô¤Î¤¦¤Á 0¸Ä°Ê¾å¤ò¥Ó¥Ã¥ÈËè¤ÎÏÀÍýÏ (bitwise-or)
261 ¤ò¤È¤Ã¤¿¤â¤Î¤ò»ØÄê¤Ç¤­¤ë¡£¤³¤ì¤é¤ÎÄê¿ô¤Ï¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤È
262 »Ò¥×¥í¥»¥¹¤Î´Ö¤Ç²¿¤ò¶¦Í­¤¹¤ë¤«¤ò»ØÄꤹ¤ë:
263 .TP
264 .\"O .BR CLONE_CHILD_CLEARTID " (since Linux 2.5.49)"
265 .BR CLONE_CHILD_CLEARTID " (Linux 2.5.49 °Ê¹ß)"
266 .\"O Erase child thread ID at location
267 .\"O .I ctid
268 .\"O in child memory when the child exits, and do a wakeup on the futex
269 .\"O at that address.
270 .\"O The address involved may be changed by the
271 .\"O .BR set_tid_address (2)
272 .\"O system call.
273 .\"O This is used by threading libraries.
274 »Ò¥×¥í¥»¥¹¤¬½ªÎ»¤·¤¿¤È¤­¤Ë»Ò¥×¥í¥»¥¹¤Î¥á¥â¥êÆâ¤Î
275 .I ctid
276 ¤¬»Ø¤¹¾ì½ê¤Ë¤¢¤ë»Ò¥×¥í¥»¥¹¤Î¥¹¥ì¥Ã¥É ID ¤ò¾Ãµî¤·¡¢
277 ¤½¤Î¥¢¥É¥ì¥¹¤Ç futex ¤ò wake (µ¯¾²) ¤µ¤»¤ë¡£
278 ¤³¤Î¥¢¥É¥ì¥¹¤Ï
279 .BR set_tid_address (2)
280 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤ÇÊѹ¹¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
281 ¤³¤Îµ¡Ç½¤Ï¥¹¥ì¥Ã¥É¥é¥¤¥Ö¥é¥ê¤Ç»ÈÍѤµ¤ì¤ë¡£
282 .TP
283 .\"O .BR CLONE_CHILD_SETTID " (since Linux 2.5.49)"
284 .BR CLONE_CHILD_SETTID " (Linux 2.5.49 °Ê¹ß)"
285 .\"O Store child thread ID at location
286 .\"O .I ctid
287 .\"O in child memory.
288 »Ò¥×¥í¥»¥¹¤Î¥á¥â¥êÆâ¤Î
289 .I ctid
290 ¤¬»Ø¤¹¾ì½ê¤Ë»Ò¥×¥í¥»¥¹¤Î¥¹¥ì¥Ã¥É ID ¤ò³ÊǼ¤¹¤ë¡£
291 .TP
292 .B CLONE_FILES
293 .\"O If
294 .\"O .B CLONE_FILES
295 .\"O is set, the calling process and the child process share the same file
296 .\"O descriptor table.
297 .\"O Any file descriptor created by the calling process or by the child
298 .\"O process is also valid in the other process.
299 .\"O Similarly, if one of the processes closes a file descriptor,
300 .\"O or changes its associated flags (using the
301 .\"O .BR fcntl (2)
302 .\"O .B F_SETFD
303 .\"O operation), the other process is also affected.
304 .B CLONE_FILES
305 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤È»Ò¥×¥í¥»¥¹¤Ï¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Î
306 ¥Æ¡¼¥Ö¥ë¤ò¶¦Í­¤¹¤ë¡£
307 ¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤È¤½¤Î»Ò¥×¥í¥»¥¹¤Î°ìÊý¤¬ºîÀ®¤·¤¿
308 ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ï¡¢¤â¤¦°ìÊý¤Ë¤ª¤¤¤Æ¤âÍ­¸ú¤Ç¤¢¤ë¡£
309 Ʊ¤¸¤è¤¦¤Ë¡¢°ìÊý¤Î¥×¥í¥»¥¹¤¬¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤òÊĤ¸¤¿¤ê¡¢
310 .RB ( fcntl (2)
311 .B F_SETFD
312 Áàºî¤ò»È¤Ã¤Æ) ¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ë´ØÏ¢¤¹¤ë¥Õ¥é¥°¤òÊѹ¹¤·¤¿¤ê¤¹¤ë¤È¡¢
313 ¤â¤¦°ìÊý¤Î¥×¥í¥»¥¹¤Ë¤â±Æ¶Á¤¹¤ë¡£
314
315 .\"O If
316 .\"O .B CLONE_FILES
317 .\"O is not set, the child process inherits a copy of all file descriptors
318 .\"O opened in the calling process at the time of
319 .\"O .BR clone ().
320 .\"O (The duplicated file descriptors in the child refer to the
321 .\"O same open file descriptions (see
322 .\"O .BR open (2))
323 .\"O as the corresponding file descriptors in the calling process.)
324 .\"O Subsequent operations that open or close file descriptors,
325 .\"O or change file descriptor flags,
326 .\"O performed by either the calling
327 .\"O process or the child process do not affect the other process.
328 .B CLONE_FILES
329 ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢»Ò¥×¥í¥»¥¹¤Ï¡¢
330 .BR clone ()
331 ¤¬¼Â¹Ô¤µ¤ì¤¿»þÅÀ¤Ç¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤¬¥ª¡¼¥×¥ó¤·¤Æ¤¤¤ëÁ´¤Æ¤Î
332 ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Î¥³¥Ô¡¼¤ò·Ñ¾µ¤¹¤ë
333 (»Ò¥×¥í¥»¥¹¤ÎÊ£À½¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ï¡¢
334 Âбþ¤¹¤ë¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤È
335 Ʊ¤¸¥Õ¥¡¥¤¥ëµ­½Ò
336 .RB ( open (2)
337 »²¾È) ¤ò»²¾È¤¹¤ë)¡£
338 ¤³¤ì°Ê¹ß¤Ë¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤È»Ò¥×¥í¥»¥¹¤Î°ìÊý¤¬
339 ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ÎÁàºî (¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Î
340 ¥ª¡¼¥×¥ó¡¦¥¯¥í¡¼¥º¤ä¡¢¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¦¥Õ¥é¥°¤ÎÊѹ¹)
341 ¤ò¹Ô¤Ã¤Æ¤â¡¢¤â¤¦°ìÊý¤Î¥×¥í¥»¥¹¤Ë¤Ï±Æ¶Á¤òÍ¿¤¨¤Ê¤¤¡£
342 .TP
343 .B CLONE_FS
344 .\"O If
345 .\"O .B CLONE_FS
346 .\"O is set, the caller and the child process share the same file system
347 .\"O information.
348 .\"O This includes the root of the file system, the current
349 .\"O working directory, and the umask.
350 .\"O Any call to
351 .\"O .BR chroot (2),
352 .\"O .BR chdir (2),
353 .\"O or
354 .\"O .BR umask (2)
355 .\"O performed by the calling process or the child process also affects the
356 .\"O other process.
357 .B CLONE_FS
358 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤È»Ò¥×¥í¥»¥¹¤¬Æ±¤¸¥Õ¥¡¥¤¥ë¡¦¥·¥¹¥Æ¥à
359 ¾ðÊó¤ò¶¦Í­¤¹¤ë¡£¥Õ¥¡¥¤¥ë¡¦¥·¥¹¥Æ¥à¾ðÊó¤Ï¡¢¥Õ¥¡¥¤¥ë¡¦¥·¥¹¥Æ¥à¤Î¥ë¡¼¥È (root)¡¢
360 ¥«¥ì¥ó¥È¡¦¥ï¡¼¥­¥ó¥°¡¦¥Ç¥£¥ì¥¯¥È¥ê (current working directory)
361 ¤ä umask ¤Ê¤É¤Ç¤¢¤ë¡£
362 ¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ä»Ò¥×¥í¥»¥¹¤Î¤É¤Á¤é¤«°ìÊý¤Ë¤è¤Ã¤Æ
363 .BR chroot (2),
364 .BR chdir (2),
365 .BR umask (2)
366 ¤¬¸Æ¤Ó½Ð¤µ¤ì¤ë¤È¡¢¤â¤¦°ìÊý¤Î¥×¥í¥»¥¹¤Ë¤â±Æ¶Á¤¬µÚ¤Ö¡£
367
368 .\"O If
369 .\"O .B CLONE_FS
370 .\"O is not set, the child process works on a copy of the file system
371 .\"O information of the calling process at the time of the
372 .\"O .BR clone ()
373 .\"O call.
374 .\"O Calls to
375 .\"O .BR chroot (2),
376 .\"O .BR chdir (2),
377 .\"O .BR umask (2)
378 .\"O performed later by one of the processes do not affect the other process.
379 .B CLONE_FS
380 ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢»Ò¥×¥í¥»¥¹¤Ï¡¢
381 .BR clone ()
382 ¤¬¼Â¹Ô¤µ¤ì¤¿»þÅÀ¤Ç¤Î¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î¥Õ¥¡¥¤¥ë¡¦¥·¥¹¥Æ¥à¾ðÊó¤Î¥³¥Ô¡¼¤ò
383 »ÈÍѤ¹¤ë¡£
384 ¤³¤ì°Ê¹ß¤Ï¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤È»Ò¥×¥í¥»¥¹¤Î°ìÊý¤¬
385 .BR chroot (2),
386 .BR chdir (2),
387 .BR umask (2)
388 ¤ò¸Æ¤Ó½Ð¤·¤Æ¤â¡¢¤â¤¦°ìÊý¤Î¥×¥í¥»¥¹¤Ë¤Ï±Æ¶Á¤òÍ¿¤¨¤Ê¤¤¡£
389 .TP
390 .\"O .BR CLONE_IO " (since Linux 2.6.25)"
391 .BR CLONE_IO " (Linux 2.6.25 °Ê¹ß)"
392 .\"O If
393 .\"O .B CLONE_IO
394 .\"O is set, then the new process shares an I/O context with
395 .\"O the calling process.
396 .\"O If this flag is not set, then (as with
397 .\"O .BR fork (2))
398 .\"O the new process has its own I/O context.
399 .B CLONE_IO
400 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢¿·¤·¤¤¥×¥í¥»¥¹¤Ï¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤È
401 I/O ¥³¥ó¥Æ¥­¥¹¥È¤ò¶¦Í­¤¹¤ë¡£
402 ¤³¤Î¥Õ¥é¥°¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ë¤Ï¡¢
403 .RB ( fork (2)
404 ¤Î¾ì¹ç¤ÈƱÍÍ) ¿·¤·¤¤¥×¥í¥»¥¹¤Ï¼«Ê¬ÀìÍѤΠI/O ¥³¥ó¥Æ¥­¥¹¥È¤ò»ý¤Ä¡£
405
406 .\" The following based on text from Jens Axboe
407 .\"O The I/O context is the I/O scope of the disk scheduler (i.e,
408 .\"O what the I/O scheduler uses to model scheduling of a process's I/O).
409 .\"O If processes share the same I/O context,
410 .\"O they are treated as one by the I/O scheduler.
411 .\"O As a consequence, they get to share disk time.
412 I/O ¥³¥ó¥Æ¥­¥¹¥È¤Ï¡¢¥Ç¥£¥¹¥¯¥¹¥±¥¸¥å¡¼¥ë¤Î I/O ¥¹¥³¡¼¥×¤Ç¤¢¤ë
413 (¸À¤¤´¹¤¨¤ë¤È¡¢I/O ¥³¥ó¥Æ¥­¥¹¥È¤Ï I/O ¥¹¥±¥¸¥å¡¼¥é¤¬¥×¥í¥»¥¹ I/O ¤Î
414 ¥¹¥±¥¸¥å¡¼¥ê¥ó¥°¤ò¥â¥Ç¥ë²½¤¹¤ë¤Î¤Ë»ÈÍѤµ¤ì¤ë)¡£
415 Ê£¿ô¤Î¥×¥í¥»¥¹¤¬Æ±¤¸ I/O ¥³¥ó¥Æ¥­¥¹¥È¤ò¶¦Í­¤¹¤ë¾ì¹ç¡¢
416 ¤³¤ì¤é¤Î¥×¥í¥»¥¹¤Ï I/O ¥¹¥±¥¸¥å¡¼¥é¤«¤é¤Ï°ì¤Ä¤È¤·¤Æ°·¤ï¤ì¤ë¡£
417 ·ë²Ì¤È¤·¤Æ¡¢¤³¤ì¤é¤Î¥×¥í¥»¥¹¤Ï¥Ç¥£¥¹¥¯¥¢¥¯¥»¥¹¤Î»þ´Ö¤ò¶¦Í­¤¹¤ë¤è¤¦¤Ë¤Ê¤ë¡£
418 .\"O For some I/O schedulers,
419 .\"O .\" the anticipatory and CFQ scheduler
420 .\"O if two processes share an I/O context,
421 .\"O they will be allowed to interleave their disk access.
422 .\"O If several threads are doing I/O on behalf of the same process
423 .\"O .RB ( aio_read (3),
424 .\"O for instance), they should employ
425 .\"O .BR CLONE_IO
426 .\"O to get better I/O performance.
427 .\"O .\" with CFQ and AS.
428 ¤¤¤¯¤Ä¤«¤Î I/O ¥¹¥±¥¸¥å¡¼¥é¤Ç¤Ï¡¢
429 .\" Í½Â¬¥¹¥±¥¸¥å¡¼¥é¤È CFQ ¥¹¥±¥¸¥å¡¼¥é
430 Æó¤Ä¤Î¥×¥í¥»¥¹¤¬ I/O ¥³¥ó¥Æ¥­¥¹¥È¤ò¶¦Í­¤·¤Æ¤¤¤ë¾ì¹ç¡¢
431 ¤³¤ì¤é¤Î¥×¥í¥»¥¹¤Ï¥Ç¥£¥¹¥¯¥¢¥¯¥»¥¹¤ò¸ò¸ß¤Ë¹Ô¤¦¤³¤È¤¬¤Ç¤­¤ë¡£
432 Ʊ¤¸¥×¥í¥»¥¹¤ÎÊ£¿ô¤Î¥¹¥ì¥Ã¥É¤¬ I/O ¤ò¼Â¹Ô¤·¤Æ¤¤¤ë¾ì¹ç
433 (Î㤨¤Ð
434 .BR aio_read (3))¡¢
435 .B CLONE_IO
436 ¤òÍøÍѤ¹¤ë¤³¤È¤Ç I/O À­Ç½¤òÎɤ¯¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
437 .\" CFQ ¤È AS ¤Î¾ì¹ç
438
439 .\"O If the kernel is not configured with the
440 .\"O .B CONFIG_BLOCK
441 .\"O option, this flag is a no-op.
442 ¥«¡¼¥Í¥ë¤ÎÀßÄ꤬
443 .B CONFIG_BLOCK
444 ¥ª¥×¥·¥ç¥óÉÕ¤­¤Ç¤Ê¤¤¾ì¹ç¡¢
445 ¤³¤Î¥Õ¥é¥°¤Ï²¿¤Î°ÕÌ£¤â»ý¤¿¤Ê¤¤¡£
446 .TP
447 .\"O .BR CLONE_NEWIPC " (since Linux 2.6.19)"
448 .BR CLONE_NEWIPC " (Linux 2.6.19 °Ê¹ß)"
449 .\"O If
450 .\"O .B CLONE_NEWIPC
451 .\"O is set, then create the process in a new IPC namespace.
452 .\"O If this flag is not set, then (as with
453 .\"O .BR fork (2)),
454 .\"O the process is created in the same IPC namespace as
455 .\"O the calling process.
456 .\"O This flag is intended for the implementation of containers.
457 .B CLONE_NEWIPC
458 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢¿·¤·¤¤ IPC Ì¾Á°¶õ´Ö (namespace) ¤Ç¥×¥í¥»¥¹¤òºîÀ®¤¹¤ë¡£
459 ¤³¤Î¥Õ¥é¥°¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢
460 .RB ( fork (2)
461 ¤Î¾ì¹ç¤ÈƱÍÍ) ¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ÈƱ¤¸ IPC Ì¾Á°¶õ´Ö¤Ç¥×¥í¥»¥¹¤¬
462 ºîÀ®¤µ¤ì¤ë¡£
463 ¤³¤Î¥Õ¥é¥°¤Ï¡¢¥³¥ó¥Æ¥Ê¤Î¼ÂÁõ¤Ç¤Î»ÈÍѤò°Õ¿Þ¤·¤ÆÍÑ°Õ¤µ¤ì¤¿¤â¤Î¤Ç¤¢¤ë¡£
464
465 .\"O An IPC namespace consists of the set of identifiers for
466 .\"O System V IPC objects.
467 .\"O (These objects are created using
468 .\"O .BR msgctl (2),
469 .\"O .BR semctl (2),
470 .\"O and
471 .\"O .BR shmctl (2)).
472 .\"O Objects created in an IPC namespace are visible to all other processes
473 .\"O that are members of that namespace,
474 .\"O but are not visible to processes in other IPC namespaces.
475 IPC Ì¾Á°¶õ´Ö¤Ï¡¢System V IPC ¥ª¥Ö¥¸¥§¥¯¥ÈÍѤμ±Ê̻Ҡ(identifiers) ¤Î
476 ½¸¹ç¤Ç¹½À®¤µ¤ì¤ë
477 (System V IPC ¥ª¥Ö¥¸¥§¥¯¥È¤Ï
478 .BR msgctl (2),
479 .BR semctl (2),
480 .BR shmctl (2)
481 ¤ò»È¤Ã¤ÆºîÀ®¤µ¤ì¤ë)¡£
482 ¤¢¤ë IPC Ì¾Á°¶õ´Ö¤ËºîÀ®¤µ¤ì¤¿¥ª¥Ö¥¸¥§¥¯¥È¤Ï¡¢
483 ¤½¤Î̾Á°¶õ´Ö¤Î¥á¥ó¥Ð¡¼¤Ç¤¢¤ë¾¤Î¤¹¤Ù¤Æ¤Î¥×¥í¥»¥¹¤«¤é¤â¸«¤¨¤ë¤¬¡¢
484 °ã¤¦ IPC Ì¾Á°¶õ´Ö¤Î¥×¥í¥»¥¹¤«¤é¤Ï¸«¤¨¤Ê¤¤¡£
485
486 .\"O When an IPC namespace is destroyed
487 .\"O (i.e, when the last process that is a member of the namespace terminates),
488 .\"O all IPC objects in the namespace are automatically destroyed.
489 IPC Ì¾Á°¶õ´Ö¤¬ÇË´þ¤µ¤ì¤ë»þ
490 (¤¹¤Ê¤ï¤Á¡¢¤½¤Î̾Á°¶õ´Ö¤Î¥á¥ó¥Ð¡¼¤ÎºÇ¸å¤Î¥×¥í¥»¥¹¤¬½ªÎ»¤¹¤ë»þ)¡¢
491 ¤½¤Î̾Á°¶õ´Ö¤ÎÁ´¤Æ¤Î IPC ¥ª¥Ö¥¸¥§¥¯¥È¤Ï¼«Æ°Åª¤ËÇË´þ¤µ¤ì¤ë¡£
492
493 .\"O Use of this flag requires: a kernel configured with the
494 .\"O .B CONFIG_SYSVIPC
495 .\"O and
496 .\"O .B CONFIG_IPC_NS
497 .\"O options and that the process be privileged
498 .\"O .RB ( CAP_SYS_ADMIN ).
499 .\"O This flag can't be specified in conjunction with
500 .\"O .BR CLONE_SYSVSEM .
501 ¤³¤Î¥Õ¥é¥°¤ò»ÈÍѤ¹¤ë¤¿¤á¤Ë¤Ï¡¢
502 ¥«¡¼¥Í¥ë¤Ç¥ª¥×¥·¥ç¥ó
503 .B CONFIG_SYSVIPC
504 ¤È
505 .B CONFIG_IPC_NS
506 ¤òÍ­¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤³¤È¡¢
507 ¥×¥í¥»¥¹¤¬Æø¢
508 .RB ( CAP_SYS_ADMIN )
509 ¤ò»ý¤Ã¤Æ¤¤¤ë¤³¤È¤¬É¬ÍפǤ¢¤ë¡£
510 ¤³¤Î¥Õ¥é¥°¤Ï
511 .B CLONE_SYSVSEM
512 ¤ÈÁȤ߹ç¤ï¤»¤Æ»È¤¦¤³¤È¤Ï¤Ç¤­¤Ê¤¤¡£
513 .TP
514 .\"O .BR CLONE_NEWNET " (since Linux 2.6.24)"
515 .BR CLONE_NEWNET " (Linux 2.6.24 °Ê¹ß)"
516 .\"O (The implementation of this flag was only completed
517 .\"O by about kernel version 2.6.29.)
518 (¤³¤Î¥Õ¥é¥°¤Î¼ÂÁõ¤Ï¡¢Linux 2.6.29 ¤¢¤¿¤ê¤Þ¤Ç¤Ë´°À®¤·¤¿¡£)
519
520 .\"O If
521 .\"O .B CLONE_NEWNET
522 .\"O is set, then create the process in a new network namespace.
523 .\"O If this flag is not set, then (as with
524 .\"O .BR fork (2)),
525 .\"O the process is created in the same network namespace as
526 .\"O the calling process.
527 .\"O This flag is intended for the implementation of containers.
528 .B CLONE_NEWNET
529 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢¿·¤·¤¤¥Í¥Ã¥È¥ï¡¼¥¯Ì¾Á°¶õ´Ö (network namaspace)
530 ¤Ç¥×¥í¥»¥¹¤òºîÀ®¤¹¤ë¡£
531 ¤³¤Î¥Õ¥é¥°¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢
532 .RB ( fork (2)
533 ¤Î¾ì¹ç¤ÈƱÍÍ) ¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ÈƱ¤¸¥Í¥Ã¥È¥ï¡¼¥¯Ì¾Á°¶õ´Ö¤Ç¥×¥í¥»¥¹¤¬
534 ºîÀ®¤µ¤ì¤ë¡£
535 ¤³¤Î¥Õ¥é¥°¤Ï¡¢¥³¥ó¥Æ¥Ê¤Î¼ÂÁõ¤Ç¤Î»ÈÍѤò°Õ¿Þ¤·¤ÆÍÑ°Õ¤µ¤ì¤¿¤â¤Î¤Ç¤¢¤ë¡£
536
537 .\"O A network namespace provides an isolated view of the networking stack
538 .\"O (network device interfaces, IPv4 and IPv6 protocol stacks,
539 .\"O IP routing tables, firewall rules, the
540 .\"O .I /proc/net
541 .\"O and
542 .\"O .I /sys/class/net
543 .\"O directory trees, sockets, etc.).
544 .\"O A physical network device can live in exactly one
545 .\"O network namespace.
546 .\"O A virtual network device ("veth") pair provides a pipe-like abstraction
547 .\"O that can be used to create tunnels between network namespaces,
548 .\"O and can be used to create a bridge to a physical network device
549 .\"O in another namespace.
550 ¥Í¥Ã¥È¥ï¡¼¥¯Ì¾Á°¶õ´Ö¤Ï¡¢Ê¬Î¥¤µ¤ì¤¿¥Í¥Ã¥È¥ï¡¼¥¯¥¹¥¿¥Ã¥¯¤òÄ󶡤¹¤ë¤â¤Î¤Ç¤¢¤ë
551 (¥Í¥Ã¥È¥ï¡¼¥¯¥¹¥¿¥Ã¥¯¤È¤Ï¡¢
552 ¥Í¥Ã¥È¥ï¡¼¥¯¥Ç¥Ð¥¤¥¹¥¤¥ó¥¿¥Õ¥§¡¼¥¹¡¢IPv4 ¤ä IPv6 ¥×¥í¥È¥³¥ë¥¹¥¿¥Ã¥¯¡¢
553 .IR /proc/net ¡¢
554 .I /sys/class/net
555 ¥Ç¥£¥ì¥¯¥È¥ê¥Ä¥ê¡¼¡¢¥½¥±¥Ã¥È¤Ê¤É¤Ç¤¢¤ë)¡£
556 ʪÍý¥Í¥Ã¥È¥ï¡¼¥¯¥Ç¥Ð¥¤¥¹¤¬½ê°¤Ç¤­¤ë¥Í¥Ã¥È¥ï¡¼¥¯Ì¾Á°¶õ´Ö¤Ï°ì¤Ä¤À¤±¤Ç¤¢¤ë¡£
557 ²¾Áۥͥåȥ¥¯¥Ç¥Ð¥¤¥¹ ("veth") ¤Î¥Ú¥¢¤Ë¤è¤ê
558 ¥Ñ¥¤¥×É÷¤ÎÃê¾Ý²½ (abstraction) ¤¬¼Â¸½¤µ¤ì¤Æ¤ª¤ê¡¢
559 ¤³¤ì¤ò»È¤¦¤³¤È¤Ç¡¢¥Í¥Ã¥È¥ï¡¼¥¯Ì¾Á°¶õ´Ö´Ö¤Î¥È¥ó¥Í¥ë¤òºîÀ®¤·¤¿¤ê¡¢
560 Ê̤Î̾Á°¶õ´Ö¤ÎʪÍý¥Í¥Ã¥È¥ï¡¼¥¯¥Ç¥Ð¥¤¥¹¤Ø¤Î¥Ö¥ê¥Ã¥¸¤òºîÀ®¤·¤¿¤ê
561 ¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
562
563 .\"O When a network namespace is freed
564 .\"O (i.e., when the last process in the namespace terminates),
565 .\"O its physical network devices are moved back to the
566 .\"O initial network namespace (not to the parent of the process).
567 ¥Í¥Ã¥È¥ï¡¼¥¯Ì¾Á°¶õ´Ö¤¬²òÊü¤µ¤ì¤ë»þ
568 (¤¹¤Ê¤ï¤Á¡¢¤½¤Î̾Á°¶õ´Ö¤ÎºÇ¸å¤Î¥×¥í¥»¥¹¤¬½ªÎ»¤¹¤ë»þ)¡¢
569 ʪÍý¥Í¥Ã¥È¥ï¡¼¥¯¥Ç¥Ð¥¤¥¹¤Ï½é´ü¥Í¥Ã¥È¥ï¡¼¥¯Ì¾Á°¶õ´Ö
570 (initial network namespace) ¤ËÌᤵ¤ì¤ë
571 (¿Æ¥×¥í¥»¥¹¤Î¥Í¥Ã¥È¥ï¡¼¥¯Ì¾Á°¶õ´Ö¤ËÌᤵ¤ì¤ëÌõ¤Ç¤Ï¤Ê¤¤)¡£
572
573 .\"O Use of this flag requires: a kernel configured with the
574 .\"O .B CONFIG_NET_NS
575 .\"O option and that the process be privileged
576 .\"O .RB ( CAP_SYS_ADMIN ).
577 ¤³¤Î¥Õ¥é¥°¤ò»ÈÍѤ¹¤ë¤¿¤á¤Ë¤Ï¡¢
578 ¥«¡¼¥Í¥ë¤Ç¥ª¥×¥·¥ç¥ó
579 .B CONFIG_NET_NS
580 ¤òÍ­¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤³¤È¡¢
581 ¥×¥í¥»¥¹¤¬Æø¢
582 .RB ( CAP_SYS_ADMIN )
583 ¤ò»ý¤Ã¤Æ¤¤¤ë¤³¤È¤¬É¬ÍפǤ¢¤ë¡£
584 .TP
585 .\"O .BR CLONE_NEWNS " (since Linux 2.4.19)"
586 .BR CLONE_NEWNS " (Linux 2.4.19 °Ê¹ß)"
587 .\"O Start the child in a new mount namespace.
588 »Ò¥×¥í¥»¥¹¤ò¿·¤·¤¤¥Þ¥¦¥ó¥È̾Á°¶õ´Ö (mount namespace) ¤Ç³«»Ï¤¹¤ë¡£
589
590 .\"O Every process lives in a mount namespace.
591 .\"O The
592 .\"O .I namespace
593 .\"O of a process is the data (the set of mounts) describing the file hierarchy
594 .\"O as seen by that process.
595 .\"O After a
596 .\"O .BR fork (2)
597 .\"O or
598 .\"O .BR clone ()
599 .\"O where the
600 .\"O .B CLONE_NEWNS
601 .\"O flag is not set, the child lives in the same mount
602 .\"O namespace as the parent.
603 ³Æ¥×¥í¥»¥¹¤Ï¤¢¤ë°ì¤Ä¤Î¥Þ¥¦¥ó¥È̾Á°¶õ´ÖÃæ¤Ë¸ºß¤¹¤ë¡£¥×¥í¥»¥¹¤Î
604 .I "̾Á°¶õ´Ö (namespace)"
605 ¤Ï¡¢¤½¤Î¥×¥í¥»¥¹¤«¤é¸«¤¨¤ë¥Õ¥¡¥¤¥ë³¬Áؤòɽ¤¹¥Ç¡¼¥¿ (mount ¤Î½¸¹ç) ¤Ç¤¢¤ë¡£
606 .B CLONE_NEWNS
607 ¥Õ¥é¥°¤¬¥»¥Ã¥È¤µ¤ì¤º¤Ë
608 .BR fork (2)
609 ¤«
610 .BR clone ()
611 ¤¬¸Æ¤Ð¤ì¤ë¤È¡¢»Ò¥×¥í¥»¥¹¤Ï¿Æ¥×¥í¥»¥¹¤ÈƱ¤¸¥Þ¥¦¥ó¥È̾Á°¶õ´Ö¤ËºîÀ®¤µ¤ì¤ë¡£
612 .\"O The system calls
613 .\"O .BR mount (2)
614 .\"O and
615 .\"O .BR umount (2)
616 .\"O change the mount namespace of the calling process, and hence affect
617 .\"O all processes that live in the same namespace, but do not affect
618 .\"O processes in a different mount namespace.
619 ¥·¥¹¥Æ¥à¥³¡¼¥ë
620 .BR mount (2)¡¢
621 .BR umount (2)
622 ¤¬¸Æ¤Ð¤ì¤ë¤È¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î¥Þ¥¦¥ó¥È̾Á°¶õ´Ö¤¬Êѹ¹¤µ¤ì¡¢¤³¤Î·ë²Ì
623 ¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ÈƱ¤¸Ì¾Á°¶õ´Ö¤Ë¤¤¤ë¥×¥í¥»¥¹¤Ï¤¹¤Ù¤Æ±Æ¶Á¤ò¼õ¤±¤ë¤¬¡¢
624 °Û¤Ê¤ë¥Þ¥¦¥ó¥È̾Á°¶õ´Ö¤Ë¤¤¤ë¥×¥í¥»¥¹¤Ï±Æ¶Á¤ò¼õ¤±¤Ê¤¤¡£
625
626 .\"O After a
627 .\"O .BR clone ()
628 .\"O where the
629 .\"O .B CLONE_NEWNS
630 .\"O flag is set, the cloned child is started in a new mount namespace,
631 .\"O initialized with a copy of the namespace of the parent.
632 .B CLONE_NEWNS
633 ¥Õ¥é¥°¤¬¥»¥Ã¥È¤µ¤ì¤Æ
634 .BR clone ()
635 ¤¬¸Æ¤Ð¤ì¤ë¤È¡¢clone ¤ÇºîÀ®¤µ¤ì¤¿»Ò¥×¥í¥»¥¹¤Ï¿·¤·¤¤¥Þ¥¦¥ó¥È̾Á°¶õ´Ö¤Ç
636 ³«»Ï¤µ¤ì¤ë¡£¿·¤·¤¤Ì¾Á°¶õ´Ö¤Ï¿Æ¥×¥í¥»¥¹¤Î̾Á°¶õ´Ö¤Î¥³¥Ô¡¼¤Ç½é´ü²½¤µ¤ì¤ë¡£
637
638 .\"O Only a privileged process (one having the \fBCAP_SYS_ADMIN\fP capability)
639 .\"O may specify the
640 .\"O .B CLONE_NEWNS
641 .\"O flag.
642 .\"O It is not permitted to specify both
643 .\"O .B CLONE_NEWNS
644 .\"O and
645 .\"O .B CLONE_FS
646 .\"O in the same
647 .\"O .BR clone ()
648 .\"O call.
649 Æø¢¥×¥í¥»¥¹ (\fBCAP_SYS_ADMIN\fP ¥±¡¼¥Ñ¥Ó¥ê¥Æ¥£¤ò»ý¤Ä¥×¥í¥»¥¹) ¤Î¤ß¤¬
650 .B CLONE_NEWNS
651 ¥Õ¥é¥°¤ò»ØÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
652 °ì¤Ä¤Î
653 .BR clone ()
654 ¸Æ¤Ó½Ð¤·¤Ç¡¢
655 .B CLONE_NEWNS
656 ¤È
657 .B CLONE_FS
658 ¤ÎξÊý¤ò»ØÄꤹ¤ë¤³¤È¤Ï¤Ç¤­¤Ê¤¤¡£
659 .TP
660 .\"O .BR CLONE_NEWPID " (since Linux 2.6.24)"
661 .BR CLONE_NEWPID " (Linux 2.6.24 °Ê¹ß)"
662 .\" This explanation draws a lot of details from
663 .\" http://lwn.net/Articles/259217/
664 .\" Authors: Pavel Emelyanov <xemul@openvz.org>
665 .\" and Kir Kolyshkin <kir@openvz.org>
666 .\"
667 .\" The primary kernel commit is 30e49c263e36341b60b735cbef5ca37912549264
668 .\" Author: Pavel Emelyanov <xemul@openvz.org>
669 .\"O If
670 .\"O .B CLONE_NEWPID
671 .\"O is set, then create the process in a new PID namespace.
672 .\"O If this flag is not set, then (as with
673 .\"O .BR fork (2)),
674 .\"O the process is created in the same PID namespace as
675 .\"O the calling process.
676 .\"O This flag is intended for the implementation of containers.
677 .B CLONE_NEWPID
678 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢¿·¤·¤¤ PID Ì¾Á°¶õ´Ö¤Ç¥×¥í¥»¥¹¤òºîÀ®¤¹¤ë¡£
679 ¤³¤Î¥Õ¥é¥°¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢
680 .RB ( fork (2)
681 ¤Î¾ì¹ç¤ÈƱÍÍ) ¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ÈƱ¤¸ PID Ì¾Á°¶õ´Ö¤Ç
682 ¥×¥í¥»¥¹¤¬ºîÀ®¤µ¤ì¤ë¡£
683 ¤³¤Î¥Õ¥é¥°¤Ï¡¢¥³¥ó¥Æ¥Ê¤Î¼ÂÁõ¤Ç¤Î»ÈÍѤò°Õ¿Þ¤·¤ÆÍÑ°Õ¤µ¤ì¤¿¤â¤Î¤Ç¤¢¤ë¡£
684
685 .\"O A PID namespace provides an isolated environment for PIDs:
686 .\"O PIDs in a new namespace start at 1,
687 .\"O somewhat like a standalone system, and calls to
688 .\"O .BR fork (2),
689 .\"O .BR vfork (2),
690 .\"O or
691 .\"O .BR clone ()
692 .\"O will produce processes with PIDs that are unique within the namespace.
693 PID Ì¾Á°¶õ´Ö¤Ï¡¢PID ¤Ë´Ø¤·¤ÆʬΥ¤µ¤ì¤¿´Ä¶­¤òÄ󶡤¹¤ë¤â¤Î¤Ç¤¢¤ë¡£
694 ¿·¤·¤¤Ì¾Á°¶õ´Ö¤Ë¤ª¤±¤ë PID ¤Ï 1 ¤«¤é»Ï¤Þ¤ê
695 (¤³¤ì¤Ï¥¹¥¿¥ó¥É¥¢¥í¥ó¤Î¥·¥¹¥Æ¥à¤È»÷¤¿¤è¤¦¤Ê´¶¤¸)¡¢
696 .BR fork (2),
697 .BR vfork (2),
698 .BR clone ()
699 ¤ò¸Æ¤Ó½Ð¤¹¤È¡¢¤½¤Î̾Á°¶õ´Ö¤Ç°ì°Õ¤Ê PID ¤ò»ý¤Ã¤¿¥×¥í¥»¥¹¤¬ºîÀ®¤µ¤ì¤ë¡£
700
701 .\"O The first process created in a new namespace
702 .\"O (i.e., the process created using the
703 .\"O .BR CLONE_NEWPID
704 .\"O flag) has the PID 1, and is the "init" process for the namespace.
705 .\"O Children that are orphaned within the namespace will be reparented
706 .\"O to this process rather than
707 .\"O .BR init (8).
708 .\"O Unlike the traditional
709 .\"O .B init
710 .\"O process, the "init" process of a PID namespace can terminate,
711 .\"O and if it does, all of the processes in the namespace are terminated.
712 ¿·¤·¤¤Ì¾Á°¶õ´Ö¤ÇºîÀ®¤µ¤ì¤ëºÇ½é¤Î¥×¥í¥»¥¹
713 (¤Ä¤Þ¤ê¡¢
714 .B CLONE_NEWPID
715 ¥Õ¥é¥°¤ò»È¤Ã¤ÆºîÀ®¤µ¤ì¤¿¥×¥í¥»¥¹) ¤Î PID ¤Ï 1 ¤Ç¤¢¤ê¡¢
716 ¤³¤Î¥×¥í¥»¥¹¤Ï¤½¤Î̾Á°¶õ´Ö¤Ë¤ª¤±¤ë "init" ¥×¥í¥»¥¹¤È¤Ê¤ë¡£
717 ¤³¤Î̾Á°¶õ´Ö¤Ë¤ª¤¤¤Æ¸É»ù (orphaned) ¤È¤Ê¤Ã¤¿»Ò¥×¥í¥»¥¹¤Ë¤Ä¤¤¤Æ¤Ï¡¢
718 .BR init (8)
719 ¤Ç¤Ï¤Ê¤¯¤³¤Î¥×¥í¥»¥¹¤¬¿Æ¥×¥í¥»¥¹¤È¤Ê¤ë¡£
720 ÀΤʤ¬¤é¤Î
721 .B init
722 ¥×¥í¥»¥¹¤È¤Ï°ã¤¤¡¢PID Ì¾Á°¶õ´Ö¤Î "init" ¥×¥í¥»¥¹¤Ï½ªÎ» (terminated) ¤¹¤ë
723 ¤³¤È¤¬¤Ç¤­¡¢¤½¤Î¾ì¹ç¤Ë¤Ï¡¢¤³¤Î̾Á°¶õ´Ö¤ÎÁ´¤Æ¤Î¥×¥í¥»¥¹¤¬½ªÎ»¤µ¤ì¤ë¡£
724
725 .\"O PID namespaces form a hierarchy.
726 PID Ì¾Á°¶õ´Ö´Ö¤Ë¤Ï³¬Áع½Â¤¤¬·ÁÀ®¤µ¤ì¤ë¡£
727 .\"O When a new PID namespace is created,
728 .\"O the processes in that namespace are visible
729 .\"O in the PID namespace of the process that created the new namespace;
730 .\"O analogously, if the parent PID namespace is itself
731 .\"O the child of another PID namespace,
732 .\"O then processes in the child and parent PID namespaces will both be
733 .\"O visible in the grandparent PID namespace.
734 ¿·¤·¤¤ PID Ì¾Á°¶õ´Ö¤¬ºîÀ®¤µ¤ì¤ë¤È¡¢¤½¤Î̾Á°¶õ´Ö¤Î¥×¥í¥»¥¹¤Ï¡¢
735 ¿·¤·¤¤Ì¾Á°¶õ´Ö¤òºîÀ®¤·¤¿¥×¥í¥»¥¹¤Î PID Ì¾Á°¶õ´Ö¤Ç¸«¤¨¤ë¡£
736 ƱÍͤˡ¢¿Æ¤Î PID Ì¾Á°¶õ´Ö¼«ÂΤ¬Ê̤ΠPID Ì¾Á°¶õ´Ö¤Î»Ò¶¡¤Î¾ì¹ç¤Ë¤Ï¡¢
737 »Ò¶¡¤Î PID Ì¾Á°¶õ´Ö¤È¿Æ¤Î PID Ì¾Á°¶õ´Ö¤Î¥×¥í¥»¥¹¤Ï¤É¤ì¤â
738 ¿Æ¤Î¿Æ¤Î PID Ì¾Á°¶õ´Ö¤Ç¤â¸«¤¨¤ë¤³¤È¤Ë¤Ê¤ë¡£
739 .\"O Conversely, the processes in the "child" PID namespace do not see
740 .\"O the processes in the parent namespace.
741 .\"O The existence of a namespace hierarchy means that each process
742 .\"O may now have multiple PIDs:
743 .\"O one for each namespace in which it is visible;
744 .\"O each of these PIDs is unique within the corresponding namespace.
745 .\"O (A call to
746 .\"O .BR getpid (2)
747 .\"O always returns the PID associated with the namespace in which
748 .\"O the process lives.)
749 È¿ÂФˡ¢¡Ö»Ò¶¡¡×¤Î PID Ì¾Á°¶õ´Ö¤Î¥×¥í¥»¥¹¤Ë¤Ï¡¢
750 ¿Æ¤Î̾Á°¶õ´Ö¤Î¥×¥í¥»¥¹¤Ï¸«¤¨¤Ê¤¤¡£
751 ̾Á°¶õ´Ö¤Ë³¬Áع½Â¤¤¬Â¸ºß¤¹¤ë¤È¤¤¤¦¤³¤È¤Ï¡¢¸Ä¡¹¤Î¥×¥í¥»¥¹¤Ï
752 Ê£¿ô¤Î PID ¤ò»ý¤Ä¤È¤¤¤¦¤³¤È¤ò°ÕÌ£¤·¤Æ¤¤¤ë¡£
753 ¤½¤Î¥×¥í¥»¥¹¤¬¸«¤¨¤ë̾Á°¶õ´Ö°ì¤Ä¤Ë¤Ä¤­ PID ¤¬°ì¤Ä¤¢¤ê¡¢
754 ¤½¤ì¤¾¤ì¤Î PID ¤ÏÂбþ¤¹¤ë̾Á°¶õ´Ö¤Ë¤ª¤¤¤Æ°ì°Õ¤Ç¤¢¤ë¡£
755 .RB ( getpid (2)
756 ¤ò¸Æ¤Ó½Ð¤¹¤È¡¢¾ï¤Ë¤½¤Î¥×¥í¥»¥¹¤¬Â¸ºß¤·¤Æ¤¤¤ë̾Á°¶õ´Ö¤Ë¤ª¤±¤ë
757 PID ¤¬ÊÖ¤µ¤ì¤ë¡£)
758
759 .\"O After creating the new namespace,
760 .\"O it is useful for the child to change its root directory
761 .\"O and mount a new procfs instance at
762 .\"O .I /proc
763 .\"O so that tools such as
764 .\"O .BR ps (1)
765 .\"O work correctly.
766 ¿·¤·¤¤Ì¾Á°¶õ´Ö¤ÎºîÀ®¸å¤Ë¤Ï¡¢
767 »Ò¥×¥í¥»¥¹¤Ë¤ª¤¤¤Æ¡¢
768 .BR ps (1)
769 ¤È¤¤¤Ã¤¿¥Ä¡¼¥ë¤¬Àµ¤·¤¯Æ°ºî¤¹¤ë¤è¤¦¤Ë¡¢
770 ¼«¿È¤Î root ¥Ç¥£¥ì¥¯¥È¥ê¤òÊѹ¹¤·¡¢
771 .I /proc
772 ¤Ë¿·¤·¤¤ procfs ¥¤¥ó¥¹¥¿¥ó¥¹¤ò¥Þ¥¦¥ó¥È¤¹¤ë¤Î¤¬¤è¤¤¤À¤í¤¦¡£
773 .\" mount -t proc proc /proc
774 .\"O (If
775 .\"O .BR CLONE_NEWNS
776 .\"O is also included in
777 .\"O .IR flags ,
778 .\"O then it isn't necessary to change the root directory:
779 .\"O a new procfs instance can be mounted directly over
780 .\"O .IR /proc .)
781 .RB ( flags
782 ¤Ë
783 .B CLONE_NEWNS
784 ¤â»ØÄꤵ¤ì¤Æ¤¤¤¿¾ì¹ç¤Ë¤Ï¡¢root ¥Ç¥£¥ì¥¯¥È¥ê¤òÊѹ¹¤¹¤ëɬÍפϤʤ¯¡¢
785 ¤¤¤­¤Ê¤ê¿·¤·¤¤ procfs ¥¤¥ó¥¹¥¿¥ó¥¹¤ò
786 .I /proc
787 ¤Ë¥Þ¥¦¥ó¥È¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£)
788
789 .\"O Use of this flag requires: a kernel configured with the
790 .\"O .B CONFIG_PID_NS
791 .\"O option and that the process be privileged
792 .\"O .RB ( CAP_SYS_ADMIN ).
793 .\"O This flag can't be specified in conjunction with
794 .\"O .BR CLONE_THREAD .
795 ¤³¤Î¥Õ¥é¥°¤ò»ÈÍѤ¹¤ë¤¿¤á¤Ë¤Ï¡¢
796 ¥«¡¼¥Í¥ë¤Ç¥ª¥×¥·¥ç¥ó
797 .B CONFIG_PID_NS
798 ¤òÍ­¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤³¤È¡¢
799 ¥×¥í¥»¥¹¤¬Æø¢
800 .RB ( CAP_SYS_ADMIN )
801 ¤ò»ý¤Ã¤Æ¤¤¤ë¤³¤È¤¬É¬ÍפǤ¢¤ë¡£
802 ¤³¤Î¥Õ¥é¥°¤Ï
803 .B CLONE_THREAD
804 ¤ÈÁȤ߹ç¤ï¤»¤Æ»È¤¦¤³¤È¤Ï¤Ç¤­¤Ê¤¤¡£
805 .TP
806 .\"O .BR CLONE_NEWUTS " (since Linux 2.6.19)"
807 .BR CLONE_NEWUTS " (Linux 2.6.19 °Ê¹ß)"
808 .\"O If
809 .\"O .B CLONE_NEWUTS
810 .\"O is set, then create the process in a new UTS namespace,
811 .\"O whose identifiers are initialized by duplicating the identifiers
812 .\"O from the UTS namespace of the calling process.
813 .\"O If this flag is not set, then (as with
814 .\"O .BR fork (2)),
815 .\"O the process is created in the same UTS namespace as
816 .\"O the calling process.
817 .\"O This flag is intended for the implementation of containers.
818 .B CLONE_NEWUTS
819 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢¿·¤·¤¤ UTS Ì¾Á°¶õ´Ö¤Ç¥×¥í¥»¥¹¤òºîÀ®¤¹¤ë¡£
820 ¿·¤·¤¤ UTS Ì¾Á°¶õ´Ö¤Î¼±Ê̻Ҥνé´üÃͤϡ¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î
821 UTS Ì¾Á°¶õ´Ö¤Î¼±Ê̻ҤòÊ£À½¤·¤¿¤â¤Î¤È¤Ê¤ë¡£
822 ¤³¤Î¥Õ¥é¥°¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢
823 .RB ( fork (2)
824 ¤Î¾ì¹ç¤ÈƱÍÍ) ¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ÈƱ¤¸ UTS Ì¾Á°¶õ´Ö¤Ç
825 ¥×¥í¥»¥¹¤¬ºîÀ®¤µ¤ì¤ë¡£
826 ¤³¤Î¥Õ¥é¥°¤Ï¡¢¥³¥ó¥Æ¥Ê¤Î¼ÂÁõ¤Ç¤Î»ÈÍѤò°Õ¿Þ¤·¤ÆÍÑ°Õ¤µ¤ì¤¿¤â¤Î¤Ç¤¢¤ë¡£
827
828 .\"O A UTS namespace is the set of identifiers returned by
829 .\"O .BR uname (2);
830 .\"O among these, the domain name and the host name can be modified by
831 .\"O .BR setdomainname (2)
832 .\"O and
833 .\"O .BR
834 .\"O .BR sethostname (2),
835 .\"O respectively.
836 .\"O Changes made to the identifiers in a UTS namespace
837 .\"O are visible to all other processes in the same namespace,
838 .\"O but are not visible to processes in other UTS namespaces.
839 UTS Ì¾Á°¶õ´Ö¤Ï¡¢
840 .BR uname (2)
841 ¤¬ÊÖ¤¹¼±Ê̻Ҥν¸¹ç¤Ç¤¢¤ë¡£
842 ¼±Ê̻ҤȤ·¤Æ¤Ï¥É¥á¥¤¥ó̾¤È¥Û¥¹¥È̾¤¬¤¢¤ê¡¢
843 ¤½¤ì¤¾¤ì
844 .BR setdomainname (2),
845 .BR sethostname (2)
846 ¤Ç½¤Àµ¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
847 ¤¢¤ë UTS Ì¾Á°¶õ´Ö¤Ë¤ª¤±¤ë¼±Ê̻ҤÎÊѹ¹¤ÏƱ¤¸Ì¾Á°¶õ´Ö¤Î¾¤Î¤¹¤Ù¤Æ¤Î
848 ¥×¥í¥»¥¹¤Ë¸«¤¨¤ë¤¬¡¢Ê̤ΠUTS Ì¾Á°¶õ´Ö¤Î¥×¥í¥»¥¹¤Ë¤Ï¸«¤¨¤Ê¤¤¡£
849
850 .\"O Use of this flag requires: a kernel configured with the
851 .\"O .B CONFIG_UTS_NS
852 .\"O option and that the process be privileged
853 .\"O .RB ( CAP_SYS_ADMIN ).
854 ¤³¤Î¥Õ¥é¥°¤ò»ÈÍѤ¹¤ë¤¿¤á¤Ë¤Ï¡¢
855 ¥«¡¼¥Í¥ë¤Ç¥ª¥×¥·¥ç¥ó
856 .B CONFIG_UTS_NS
857 ¤òÍ­¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤³¤È¡¢
858 ¥×¥í¥»¥¹¤¬Æø¢
859 .RB ( CAP_SYS_ADMIN )
860 ¤ò»ý¤Ã¤Æ¤¤¤ë¤³¤È¤¬É¬ÍפǤ¢¤ë¡£
861 .TP
862 .\"O .BR CLONE_PARENT " (since Linux 2.3.12)"
863 .BR CLONE_PARENT " (Linux 2.3.12 °Ê¹ß)"
864 .\"O If
865 .\"O .B CLONE_PARENT
866 .\"O is set, then the parent of the new child (as returned by
867 .\"O .BR getppid (2))
868 .\"O will be the same as that of the calling process.
869 .B CLONE_PARENT
870 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢¿·¤·¤¤»Ò¶¡¤Î
871 .RB ( getppid (2)
872 ¤ÇÊÖ¤µ¤ì¤ë) ¿Æ¥×¥í¥»¥¹¤Ï¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î¿Æ¥×¥í¥»¥¹¤ÈƱ¤¸¤Ë¤Ê¤ë¡£
873
874 .\"O If
875 .\"O .B CLONE_PARENT
876 .\"O is not set, then (as with
877 .\"O .BR fork (2))
878 .\"O the child's parent is the calling process.
879 .B CLONE_PARENT
880 ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢
881 .RB ( fork (2)
882 ¤ÈƱÍͤË) ¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤¬¤½¤Î»Ò¶¡¤Î¿Æ¤Ë¤Ê¤ë¡£
883
884 .\"O Note that it is the parent process, as returned by
885 .\"O .BR getppid (2),
886 .\"O which is signaled when the child terminates, so that
887 .\"O if
888 .\"O .B CLONE_PARENT
889 .\"O is set, then the parent of the calling process, rather than the
890 .\"O calling process itself, will be signaled.
891 »Ò¶¡¤¬½ªÎ»¤·¤¿»þ¤Ë¥·¥°¥Ê¥ë¤¬Á÷¤é¤ì¤ë¤Î¤Ï
892 .BR getppid (2)
893 ¤¬ÊÖ¤¹¿Æ¥×¥í¥»¥¹¤Ç¤¢¤ëÅÀ¤ËÃí°Õ¤¹¤ë¤³¤È¡£¤³¤Î¤¿¤á
894 .B CLONE_PARENT
895 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Ç¤Ï¤Ê¤¯¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î
896 ¿Æ¥×¥í¥»¥¹¤Ë¥·¥°¥Ê¥ë¤¬Á÷¤é¤ì¤ë¡£
897 .TP
898 .\"O .BR CLONE_PARENT_SETTID " (since Linux 2.5.49)"
899 .BR CLONE_PARENT_SETTID " (Linux 2.5.49 °Ê¹ß)"
900 .\"O Store child thread ID at location
901 .\"O .I ptid
902 .\"O in parent and child memory.
903 .\"O (In Linux 2.5.32-2.5.48 there was a flag
904 .\"O .B CLONE_SETTID
905 .\"O that did this.)
906 ¿Æ¥×¥í¥»¥¹¤È»Ò¥×¥í¥»¥¹¤Î¥á¥â¥êÆâ¤Î
907 .I ptid
908 ¤¬»Ø¤¹Îΰè¤Ë»Ò¥×¥í¥»¥¹¤Î¥¹¥ì¥Ã¥É ID ¤ò³ÊǼ¤¹¤ë¡£
909 (Linux 2.5.32-2.5.48 ¤Ç¤Ï¡¢
910 Ʊ¤¸¤³¤È¤ò¤¹¤ë
911 .B CLONE_SETTID
912 ¤È¤¤¤¦¥Õ¥é¥°¤¬Â¸ºß¤·¤¿¡£)
913 .TP
914 .\"O .BR CLONE_PID " (obsolete)"
915 .BR CLONE_PID " (ÇÑ»ßͽÄê)"
916 .\"O If
917 .\"O .B CLONE_PID
918 .\"O is set, the child process is created with the same process ID as
919 .\"O the calling process.
920 .\"O This is good for hacking the system, but otherwise
921 .\"O of not much use.
922 .\"O Since 2.3.21 this flag can be
923 .\"O specified only by the system boot process (PID 0).
924 .\"O It disappeared in Linux 2.5.16.
925 .B CLONE_PID
926 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢»Ò¥×¥í¥»¥¹¤Ï¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ÈƱ¤¸¥×¥í¥»¥¹ ID
927 ¤ÇºîÀ®¤µ¤ì¤ë¡£¤³¤ì¤Ï¥·¥¹¥Æ¥à¤ò¥Ï¥Ã¥­¥ó¥°¤¹¤ë¤Î¤Ë¤ÏÊØÍø¤À¤¬¡¢
928 ¤½¤ì°Ê³°¤Ë¤Ï¤¢¤Þ¤ê»È¤ï¤ì¤Ê¤¤¡£ Linux 2.3.21 °Ê¹ß¤Ç¤Ï¡¢
929 ¥·¥¹¥Æ¥à¤Î¥Ö¡¼¥È¥×¥í¥»¥¹ (PID 0) ¤À¤±¤¬¤³¤Î¥Õ¥é¥°¤ò»ØÄê¤Ç¤­¤ë¡£
930 Linux 2.5.16 ¤Çºï½ü¤µ¤ì¤¿¡£
931 .TP
932 .B CLONE_PTRACE
933 .\"O If
934 .\"O .B CLONE_PTRACE
935 .\"O is specified, and the calling process is being traced,
936 .\"O then trace the child also (see
937 .\"O .BR ptrace (2)).
938 .B CLONE_PTRACE
939 ¤¬»ØÄꤵ¤ì¡¢¤«¤Ä¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤¬ÄÉÀ× (trace) ¤µ¤ì¤Æ¤¤¤¿¾ì¹ç¡¢»Ò¥×¥í¥»¥¹¤â
940 ƱÍͤËÄÉÀפµ¤ì¤ë¡£
941 .RB ( ptrace (2)
942 ¤ò»²¾È¤Î¤³¤È)
943 .TP
944 .\"O .BR CLONE_SETTLS " (since Linux 2.5.32)"
945 .BR CLONE_SETTLS " (Linux 2.5.32 °Ê¹ß)"
946 .\"O The
947 .\"O .I newtls
948 .\"O argument is the new TLS (Thread Local Storage) descriptor.
949 .\"O (See
950 .\"O .BR set_thread_area (2).)
951 .I newtls
952 °ú¤­¿ô¤Ï¡¢¿·¤·¤¤ TLS (Thread Local Storage) ¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç¤¢¤ë¡£
953 .RB ( set_thread_area (2)
954 ¤ò»²¾È¤Î¤³¤È)
955 .TP
956 .B CLONE_SIGHAND
957 .\"O If
958 .\"O .B CLONE_SIGHAND
959 .\"O is set, the calling process and the child process share the same table of
960 .\"O signal handlers.
961 .\"O If the calling process or child process calls
962 .\"O .BR sigaction (2)
963 .\"O to change the behavior associated with a signal, the behavior is
964 .\"O changed in the other process as well.
965 .\"O However, the calling process and child
966 .\"O processes still have distinct signal masks and sets of pending
967 .\"O signals.
968 .\"O So, one of them may block or unblock some signals using
969 .\"O .BR sigprocmask (2)
970 .\"O without affecting the other process.
971 .B CLONE_SIGHAND
972 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤È»Ò¥×¥í¥»¥¹¤ÏƱ¤¸¥·¥°¥Ê¥ë¡¦¥Ï¥ó
973 ¥É¥é¤Î¥Æ¡¼¥Ö¥ë¤ò¶¦Í­¤¹¤ë¡£¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Þ¤¿¤Ï»Ò¥×¥í¥»¥¹¤Î¤É¤Á¤é¤«¤¬
974 .BR sigaction (2)
975 ¤ò¸Æ¤Ó½Ð¤·¤Æ¥·¥°¥Ê¥ë¤ËÂбþ¤¹¤ëÆ°ºî¤òÊѹ¹¤·¤¿¾ì¹ç¡¢
976 ¤â¤¦°ìÊý¤Î¥×¥í¥»¥¹¤Î¥·¥°¥Ê¥ëÆ°ºî¤âÊѹ¹¤µ¤ì¤ë¡£
977 ⤷¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤È»Ò¥×¥í¥»¥¹¤Ï¡¢
978 ¥×¥í¥»¥¹Ëè¤Ë¡¢¥·¥°¥Ê¥ë¡¦¥Þ¥¹¥¯ (signal mask) ¤È½èÍýÂÔ¤Á¥·¥°¥Ê¥ë¤Î½¸¹ç
979 ¤ò»ý¤Ã¤Æ¤¤¤ë¡£¤³¤Î¤¿¤á¡¢¤¢¤ë¥×¥í¥»¥¹¤Ï¡¢
980 .BR sigprocmask (2)
981 ¤ò»ÈÍѤ·¤Æ¡¢¤â¤¦°ìÊý¤Î¥×¥í¥»¥¹¤Ë±Æ¶Á¤òÍ¿¤¨¤º¤Ë
982 ¥·¥°¥Ê¥ë¤ò¶Ø»ß (block) ¤·¤¿¤êµö²Ä (unblock) ¤·¤¿¤ê¤Ç¤­¤ë¡£
983
984 .\"O If
985 .\"O .B CLONE_SIGHAND
986 .\"O is not set, the child process inherits a copy of the signal handlers
987 .\"O of the calling process at the time
988 .\"O .BR clone ()
989 .\"O is called.
990 .\"O Calls to
991 .\"O .BR sigaction (2)
992 .\"O performed later by one of the processes have no effect on the other
993 .\"O process.
994 .B CLONE_SIGHAND
995 ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢»Ò¥×¥í¥»¥¹¤Ï
996 .BR clone ()
997 ¤¬¼Â¹Ô¤µ¤ì¤¿»þÅÀ¤Ç¤Î¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î¥·¥°¥Ê¥ë¡¦¥Ï¥ó¥É¥é¤Î
998 ¥³¥Ô¡¼¤ò·Ñ¾µ¤¹¤ë¡£¤³¤ì°Ê¹ß¤Ï¡¢°ìÊý¤Î¥×¥í¥»¥¹¤¬
999 .BR sigaction (2)
1000 ¤ò¸Æ¤Ó½Ð¤·¤Æ¤â¡¢¤â¤¦°ìÊý¤Î¥×¥í¥»¥¹¤Ë¤Ï±Æ¶Á¤òÍ¿¤¨¤Ê¤¤¡£
1001
1002 .\"O Since Linux 2.6.0-test6,
1003 .\"O .I flags
1004 .\"O must also include
1005 .\"O .B CLONE_VM
1006 .\"O if
1007 .\"O .B CLONE_SIGHAND
1008 .\"O is specified
1009 Linux 2.6.0-test6 °Ê¹ß¤Ç¤Ï¡¢
1010 .B CLONE_SIGHAND
1011 ¤ò»ØÄꤹ¤ë¾ì¹ç¡¢
1012 .B CLONE_VM
1013 ¤â
1014 .I flags
1015 ¤Ë´Þ¤á¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
1016 .TP
1017 .\"O .BR CLONE_STOPPED " (since Linux 2.6.0-test2)"
1018 .BR CLONE_STOPPED " (Linux 2.6.0-test2 °Ê¹ß)"
1019 .\"O If
1020 .\"O .B CLONE_STOPPED
1021 .\"O is set, then the child is initially stopped (as though it was sent a
1022 .\"O .B SIGSTOP
1023 .\"O signal), and must be resumed by sending it a
1024 .\"O .B SIGCONT
1025 .\"O signal.
1026 .B CLONE_STOPPED
1027 ¤¬ÀßÄꤵ¤ì¤ë¤È¡¢»Ò¥×¥í¥»¥¹¤ÏºÇ½é
1028 .RB ( SIGSTOP
1029 ¥·¥°¥Ê¥ë¤òÁ÷¤é¤ì¤¿¤«¤Î¤è¤¦¤Ë) Ää»ß¤·¤¿¾õÂ֤Ȥʤ롣
1030 »Ò¥×¥í¥»¥¹¤òºÆ³«¤µ¤»¤ë¤Ë¤Ï
1031 .B SIGCONT
1032 ¥·¥°¥Ê¥ë¤òÁ÷¿®¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
1033
1034 .\"O .I "From Linux 2.6.25 this flag is deprecated."
1035 .\"O You probably never wanted to use it,
1036 .\"O you certainly shouldn't be using it, and soon it will go away.
1037 .I "Linux 2.6.25 °Ê¹ß¡¢¤³¤Î¥Õ¥é¥°¤ÏÈó¿ä¾©¤Ç¤¢¤ë¡£"
1038 ¤³¤Î¥Õ¥é¥°¤ò»È¤¤¤¿¤¤¤È»×¤¦¤³¤È¤Ï·è¤·¤Æ¤Ê¤¤¤À¤í¤¦¤·¡¢
1039 ³Î¼Â¤Ë»È¤ï¤Ê¤¤¤è¤¦¤Ë¤¹¤Ù¤­¤Ç¤¢¤ë¡£
1040 ¤³¤Î¥Õ¥é¥°¤Ï¶á¤¤¤¦¤Á¤Ë¤Ê¤¯¤Ê¤ë¤³¤È¤À¤í¤¦¡£
1041 .\" glibc 2.8 removed this defn from bits/sched.h
1042 .TP
1043 .\"O .BR CLONE_SYSVSEM " (since Linux 2.5.10)"
1044 .BR CLONE_SYSVSEM " (Linux 2.5.10 °Ê¹ß)"
1045 .\"O If
1046 .\"O .B CLONE_SYSVSEM
1047 .\"O is set, then the child and the calling process share
1048 .\"O a single list of System V semaphore undo values (see
1049 .\"O .BR semop (2)).
1050 .\"O If this flag is not set, then the child has a separate undo list,
1051 .\"O which is initially empty.
1052 .B CLONE_SYSVSEM
1053 ¤¬¥»¥Ã¥È¤µ¤ì¤ë¤È¡¢»Ò¥×¥í¥»¥¹¤È¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Ï°ì¤Ä¤Î
1054 System V ¥»¥Þ¥Õ¥©¤Î¥¢¥ó¥É¥¥Ãͥꥹ¥È
1055 .RB ( semop (2)
1056 »²¾È) ¤ò¶¦Í­¤¹¤ë¡£¤³¤Î¥Õ¥é¥°¤¬¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢
1057 »Ò¥×¥í¥»¥¹¤ÏÆȼ«¤Î¥¢¥ó¥É¥¥¥ê¥¹¥È¤ò»ý¤Ä (¥ê¥¹¥È¤Î½é´üÃͤ϶õ¤Ç¤¢¤ë)¡£
1058 .TP
1059 .\"O .BR CLONE_THREAD " (since Linux 2.4.0-test8)"
1060 .BR CLONE_THREAD " (Linux 2.4.0-test8°Ê¹ß)"
1061 .\"O If
1062 .\"O .B CLONE_THREAD
1063 .\"O is set, the child is placed in the same thread group as the calling process.
1064 .\"O To make the remainder of the discussion of
1065 .\"O .B CLONE_THREAD
1066 .\"O more readable, the term "thread" is used to refer to the
1067 .\"O processes within a thread group.
1068 .B CLONE_THREAD
1069 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢»Ò¥×¥í¥»¥¹¤Ï¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ÈƱ¤¸¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Ë
1070 ÃÖ¤«¤ì¤ë¡£
1071 .B CLONE_THREAD
1072 ¤Ë¤Ä¤¤¤Æ¤Î°Ê¹ß¤ÎµÄÏÀ¤òÆɤߤ䤹¤¯¤¹¤ë¤¿¤á¡¢
1073 ¡Ö¥¹¥ì¥Ã¥É¡×¤È¤¤¤¦ÍѸì¤Ï¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤ÎÃæ¤Î¥×¥í¥»¥¹¤ò
1074 »²¾È¤¹¤ë¤Î¤Ë»È¤¦¤³¤È¤È¤¹¤ë¡£
1075
1076 .\"O Thread groups were a feature added in Linux 2.4 to support the
1077 .\"O POSIX threads notion of a set of threads that share a single PID.
1078 .\"O Internally, this shared PID is the so-called
1079 .\"O thread group identifier (TGID) for the thread group.
1080 .\"O Since Linux 2.4, calls to
1081 .\"O .BR getpid (2)
1082 .\"O return the TGID of the caller.
1083 ¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Ï¡¢ ¥¹¥ì¥Ã¥É½¸¹ç¤Ç°ì¤Ä¤Î PID ¤ò¶¦Í­¤¹¤ë¤È¤¤¤¦ POSIX
1084 ¥¹¥ì¥Ã¥É¤Î³µÇ°¤ò¥µ¥Ý¡¼¥È¤¹¤ë¤¿¤á¤Ë Linux 2.4 ¤Ë²Ã¤¨¤é¤ì¤¿µ¡Ç½¤Ç¤¢¤Ã¤¿¡£
1085 ÆâÉôŪ¤Ë¤Ï¡¢¤³¤Î¶¦Í­ PID ¤Ï¤¤¤ï¤æ¤ë¤½¤Î¥¹¥ì¥Ã¥É¥°¥ë¡¼¥×¤Î
1086 ¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¼±Ê̻Ҡ(TGID) ¤Ç¤¢¤ë¡£
1087 Linux 2.4 °Ê¹ß¤Ç¤Ï¡¢
1088 .BR getpid (2)
1089 ¤Î¸Æ¤Ó½Ð¤·¤Ç¤Ï¤½¤Î¥×¥í¥»¥¹¤Î¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥× ID ¤òÊÖ¤¹¡£
1090
1091 .\"O The threads within a group can be distinguished by their (system-wide)
1092 .\"O unique thread IDs (TID).
1093 .\"O A new thread's TID is available as the function result
1094 .\"O returned to the caller of
1095 .\"O .BR clone (),
1096 .\"O and a thread can obtain
1097 .\"O its own TID using
1098 .\"O .BR gettid (2).
1099 ¤¢¤ë¥°¥ë¡¼¥×¤Ë°¤¹¤ë¥¹¥ì¥Ã¥É¤Ï (¥·¥¹¥Æ¥àÁ´ÂΤÇ) °ì°Õ¤Ê¥¹¥ì¥Ã¥É ID (TID)
1100 ¤Ç¶èÊ̤Ǥ­¤ë¡£¿·¤·¤¤¥¹¥ì¥Ã¥É¤Î TID ¤Ï
1101 .BR clone ()
1102 ¤Î¸Æ¤Ó½Ð¤·¸µ¤Ø´Ø¿ô¤Î·ë²Ì¤È¤·¤ÆÊÖ¤µ¤ì¡¢
1103 ¥¹¥ì¥Ã¥É¤Ï¼«Ê¬¼«¿È¤Î TID ¤ò
1104 .BR gettid (2)
1105 ¤Ç¼èÆÀ¤Ç¤­¤ë¡£
1106
1107 .\"O When a call is made to
1108 .\"O .BR clone ()
1109 .\"O without specifying
1110 .\"O .BR CLONE_THREAD ,
1111 .\"O then the resulting thread is placed in a new thread group
1112 .\"O whose TGID is the same as the thread's TID.
1113 .\"O This thread is the
1114 .\"O .I leader
1115 .\"O of the new thread group.
1116 .B CLONE_THREAD
1117 ¤ò»ØÄꤻ¤º¤Ë
1118 .BR clone ()
1119 ¤Î¸Æ¤Ó½Ð¤·¤¬¹Ô¤ï¤ì¤ë¤È¡¢
1120 À¸À®¤µ¤ì¤¿¥¹¥ì¥Ã¥É¤Ï¤½¤Î¥¹¥ì¥Ã¥É¤Î TID ¤ÈƱ¤¸ÃͤΠTGID ¤ò»ý¤Ä
1121 ¿·¤·¤¤¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤ËÃÖ¤«¤ì¤ë¡£¤³¤Î¥¹¥ì¥Ã¥É¤Ï
1122 ¿·¤·¤¤¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Î¡Ö¥ê¡¼¥À¡¼¡×¤Ç¤¢¤ë¡£
1123
1124 .\"O A new thread created with
1125 .\"O .B CLONE_THREAD
1126 .\"O has the same parent process as the caller of
1127 .\"O .BR clone ()
1128 .\"O (i.e., like
1129 .\"O .BR CLONE_PARENT ),
1130 .\"O so that calls to
1131 .\"O .BR getppid (2)
1132 .\"O return the same value for all of the threads in a thread group.
1133 .B CLONE_THREAD
1134 ¤ò»ØÄꤷ¤ÆºîÀ®¤µ¤ì¤¿¿·¤·¤¤¥¹¥ì¥Ã¥É¤Ï¡¢
1135 .RB ( CLONE_PARENT
1136 ¤Î¾ì¹ç¤ÈƱÍͤË)
1137 .BR clone ()
1138 ¤ò¸Æ¤Ó½Ð¤·¸µ¤ÈƱ¤¸¿Æ¥×¥í¥»¥¹¤ò»ý¤Ä¡£
1139 ¤½¤Î¤¿¤á¡¢
1140 .BR getppid (2)
1141 ¤ò¸Æ¤Ö¤È¡¢°ì¤Ä¤Î¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Ë°¤¹¥¹¥ì¥Ã¥É¤ÏÁ´¤ÆƱ¤¸ÃͤòÊÖ¤¹¡£
1142 .\"O When a
1143 .\"O .B CLONE_THREAD
1144 .\"O thread terminates, the thread that created it using
1145 .\"O .BR clone ()
1146 .\"O is not sent a
1147 .\"O .B SIGCHLD
1148 .\"O (or other termination) signal;
1149 .\"O nor can the status of such a thread be obtained
1150 .\"O using
1151 .\"O .BR wait (2).
1152 .\"O (The thread is said to be
1153 .\"O .IR detached .)
1154 .B CLONE_THREAD
1155 ¤Çºî¤é¤ì¤¿¥¹¥ì¥Ã¥É¤¬½ªÎ»¤·¤¿ºÝ¤Ë¡¢
1156 ¤½¤Î¥¹¥ì¥Ã¥É¤ò
1157 .BR clone ()
1158 ¤ò»È¤Ã¤ÆÀ¸À®¤·¤¿¥¹¥ì¥Ã¥É¤Ë¤Ï
1159 .B SIGCHLD
1160 (¤â¤·¤¯¤Ï¾¤Î½ªÎ»¥·¥°¥Ê¥ë) ¤ÏÁ÷¿®¤µ¤ì¤Ê¤¤¡£
1161 ¤Þ¤¿¡¢
1162 .BR wait (2)
1163 ¤ò»È¤Ã¤Æ½ªÎ»¤·¤¿¥¹¥ì¥Ã¥É¤Î¾õÂÖ¤ò¼èÆÀ¤¹¤ë¤³¤È¤â¤Ç¤­¤Ê¤¤
1164 (¤½¤Î¤è¤¦¤Ê¥¹¥ì¥Ã¥É¤Ï
1165 .I detached
1166 (ʬΥ¤µ¤ì¤¿) ¤È¤¤¤ï¤ì¤ë)¡£
1167
1168 .\"O After all of the threads in a thread group terminate
1169 .\"O the parent process of the thread group is sent a
1170 .\"O .B SIGCHLD
1171 .\"O (or other termination) signal.
1172 ¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Ë°¤¹Á´¤Æ¤Î¥¹¥ì¥Ã¥É¤¬½ªÎ»¤·¤¿¸å¡¢
1173 ¤½¤Î¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Î¿Æ¥×¥í¥»¥¹¤Ë
1174 .B SIGCHLD
1175 (¤â¤·¤¯¤Ï¾¤Î½ªÎ»¥·¥°¥Ê¥ë) ¤¬Á÷¤é¤ì¤ë¡£
1176
1177 .\"O If any of the threads in a thread group performs an
1178 .\"O .BR execve (2),
1179 .\"O then all threads other than the thread group leader are terminated,
1180 .\"O and the new program is executed in the thread group leader.
1181 ¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Ë°¤¹¤¤¤º¤ì¤«¤Î¥¹¥ì¥Ã¥É¤¬
1182 .BR execve (2)
1183 ¤ò¼Â¹Ô¤¹¤ë¤È¡¢¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¡¦¥ê¡¼¥À¡¼°Ê³°¤ÎÁ´¤Æ¤Î¥¹¥ì¥Ã¥É¤Ï
1184 ½ªÎ»¤µ¤ì¡¢¿·¤·¤¤¥×¥í¥»¥¹¤¬¤½¤Î¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¡¦¥ê¡¼¥À¡¼¤Î²¼¤Ç
1185 ¼Â¹Ô¤µ¤ì¤ë¡£
1186
1187 .\"O If one of the threads in a thread group creates a child using
1188 .\"O .BR fork (2),
1189 .\"O then any thread in the group can
1190 .\"O .BR wait (2)
1191 .\"O for that child.
1192 ¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Ë°¤¹¥¹¥ì¥Ã¥É¤Î°ì¤Ä¤¬
1193 .BR fork (2)
1194 ¤ò»È¤Ã¤Æ»Ò¥×¥í¥»¥¹¤òºîÀ®¤·¤¿¾ì¹ç¡¢
1195 ¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Î¤É¤Î¥¹¥ì¥Ã¥É¤Ç¤¢¤Ã¤Æ¤â
1196 ¤½¤Î»Ò¶¡¤ò
1197 .BR wait (2)
1198 ¤Ç¤­¤ë¡£
1199
1200 .\"O Since Linux 2.5.35,
1201 .\"O .I flags
1202 .\"O must also include
1203 .\"O .B CLONE_SIGHAND
1204 .\"O if
1205 .\"O .B CLONE_THREAD
1206 .\"O is specified.
1207 Linux 2.5.35 °Ê¹ß¤Ç¤Ï¡¢
1208 .B CLONE_THREAD
1209 ¤ò»ØÄꤹ¤ë¾ì¹ç¡¢
1210 .I flags
1211 ¤Ë
1212 .B CLONE_SIGHAND
1213 ¤â´Þ¤Þ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
1214
1215 .\"O Signals may be sent to a thread group as a whole (i.e., a TGID) using
1216 .\"O .BR kill (2),
1217 .\"O or to a specific thread (i.e., TID) using
1218 .\"O .BR tgkill (2).
1219 .BR kill (2)
1220 ¤ò»È¤Ã¤Æ¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×Á´ÂΠ(¤Ä¤Þ¤ê TGID) ¤Ë¥·¥°¥Ê¥ë¤òÁ÷¤ë¤³¤È¤â¤Ç¤­¤ì¤Ð¡¢
1221 .BR tgkill (2)
1222 ¤ò»È¤Ã¤ÆÆÃÄê¤Î¥¹¥ì¥Ã¥É (¤Ä¤Þ¤ê TID) ¤Ë¥·¥°¥Ê¥ë¤òÁ÷¤ë¤³¤È¤â¤Ç¤­¤ë¡£
1223
1224 .\"O Signal dispositions and actions are process-wide:
1225 .\"O if an unhandled signal is delivered to a thread, then
1226 .\"O it will affect (terminate, stop, continue, be ignored in)
1227 .\"O all members of the thread group.
1228 ¥·¥°¥Ê¥ë¤ÎÇÛÁ÷¤È½èÍý¤Ï¥×¥í¥»¥¹Á´ÂΤ˱ƶÁ¤¹¤ë:
1229 ¥Ï¥ó¥É¥é¤òÀßÄꤷ¤Æ¤¤¤Ê¤¤¥·¥°¥Ê¥ë¤¬¤¢¤ë¥¹¥ì¥Ã¥É¤ËÇÛÁ÷¤µ¤ì¤ë¤È¡¢
1230 ¤½¤Î¥·¥°¥Ê¥ë¤Ï¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤ÎÁ´¥á¥ó¥Ð¡¼¤Ë±Æ¶Á¤òµÚ¤Ü¤¹
1231 (½ªÎ»¤·¤¿¤ê¡¢Ää»ß¤·¤¿¤ê¡¢Æ°ºî¤ò·Ñ³¤·¤¿¤ê¡¢Ìµ»ë¤µ¤ì¤¿¤ê¤¹¤ë)¡£
1232
1233 .\"O Each thread has its own signal mask, as set by
1234 .\"O .BR sigprocmask (2),
1235 .\"O but signals can be pending either: for the whole process
1236 .\"O (i.e., deliverable to any member of the thread group),
1237 .\"O when sent with
1238 .\"O .BR kill (2);
1239 .\"O or for an individual thread, when sent with
1240 .\"O .BR tgkill (2).
1241 .\"O A call to
1242 .\"O .BR sigpending (2)
1243 .\"O returns a signal set that is the union of the signals pending for the
1244 .\"O whole process and the signals that are pending for the calling thread.
1245 ³Æ¡¹¤Î¥¹¥ì¥Ã¥É¤ÏÆȼ«¤Î¥·¥°¥Ê¥ë¥Þ¥¹¥¯¤ò»ý¤Ã¤Æ¤ª¤ê¡¢
1246 .BR sigprocmask (2)
1247 ¤ÇÀßÄê¤Ç¤­¤ë¡£
1248 ¤À¤¬¡¢½èÍýÂÔ¤Á¤Î¥·¥°¥Ê¥ë¤Ë¤Ï¡¢
1249 .BR kill (2)
1250 ¤ÇÁ÷¿®¤µ¤ì¤ë¥×¥í¥»¥¹Á´ÂΤËÂФ¹¤ë¤â¤Î (¤Ä¤Þ¤ê¡¢¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Î
1251 ¤É¤Î¥á¥ó¥Ð¡¼¤Ë¤âÇÛÁ÷¤Ç¤­¤ë¤â¤Î) ¤È¡¢
1252 .BR tgkill (2)
1253 ¤ÇÁ÷¿®¤µ¤ì¤ë¸Ä¡¹¤Î¥¹¥ì¥Ã¥É¤ËÂФ¹¤ë¤â¤Î¤¬¤¢¤ê¤¨¤ë¡£
1254 .BR sigpending (2)
1255 ¤ò¸Æ¤Ó½Ð¤¹¤È¡¢¥×¥í¥»¥¹Á´ÂΤËÂФ¹¤ë½èÍýÂÔ¤Á¥·¥°¥Ê¥ë¤È¸Æ¤Ó½Ð¤·¸µ¤Î
1256 ¥¹¥ì¥Ã¥É¤ËÂФ¹¤ë½èÍýÂÔ¤Á¥·¥°¥Ê¥ë¤ò·ë¹ç¤·¤¿¥·¥°¥Ê¥ë½¸¹ç¤¬ÊÖ¤µ¤ì¤ë¡£
1257
1258 .\"O If
1259 .\"O .BR kill (2)
1260 .\"O is used to send a signal to a thread group,
1261 .\"O and the thread group has installed a handler for the signal, then
1262 .\"O the handler will be invoked in exactly one, arbitrarily selected
1263 .\"O member of the thread group that has not blocked the signal.
1264 .\"O If multiple threads in a group are waiting to accept the same signal using
1265 .\"O .BR sigwaitinfo (2),
1266 .\"O the kernel will arbitrarily select one of these threads
1267 .\"O to receive a signal sent using
1268 .\"O .BR kill (2).
1269 .BR kill (2)
1270 ¤ò»È¤Ã¤Æ¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Ë¥·¥°¥Ê¥ë¤¬Á÷¤é¤ì¤¿¾ì¹ç¤Ç¡¢
1271 ¤½¤Î¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤¬¤½¤Î¥·¥°¥Ê¥ë¤ËÂФ¹¤ë¥·¥°¥Ê¥ë¡¦¥Ï¥ó¥É¥é¤¬
1272 ÅÐÏ¿¤µ¤ì¤Æ¤¤¤¿¤È¤­¤Ë¤Ï¡¢¥·¥°¥Ê¥ë¡¦¥Ï¥ó¥É¥é¤Ï¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Î
1273 ¥á¥ó¥Ð¡¼¤Î¤¦¤Á¡¢¤¿¤À°ì¤Ä¤Î¥¹¥ì¥Ã¥É¤Ç¤À¤±µ¯Æ°¤µ¤ì¤ë¡£¥Ï¥ó¥É¥é¤¬
1274 µ¯Æ°¤µ¤ì¤ë¥¹¥ì¥Ã¥É¤Ï¡¢¤½¤Î¥·¥°¥Ê¥ë¤ò¶Ø»ß (block) ¤·¤Æ¤¤¤Ê¤¤
1275 ¥á¥ó¥Ð¡¼¤ÎÃ椫¤é°ì¤Ä¤À¤±¤¬¾¡¼ê¤Ë (arbitrarily) Áª¤Ð¤ì¤ë¡£
1276 ¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Ë°¤¹Ê£¿ô¤Î¥¹¥ì¥Ã¥É¤¬
1277 .BR sigwaitinfo (2)
1278 ¤ò»È¤Ã¤ÆƱ¤¸¥·¥°¥Ê¥ë¤òÂԤäƤ¤¤ë¾ì¹ç¡¢
1279 ¤³¤ì¤é¤Î¥¹¥ì¥Ã¥É¤ÎÃ椫¤é°ì¤Ä¤ò¥«¡¼¥Í¥ë¤¬¾¡¼ê¤ËÁªÂò¤·¡¢
1280 ¤½¤Î¥¹¥ì¥Ã¥É¤¬
1281 .B kill (2)
1282 ¤ò»È¤Ã¤ÆÁ÷¿®¤µ¤ì¤¿¥·¥°¥Ê¥ë¤ò¼õ¿®¤¹¤ë¡£
1283 .TP
1284 .\"O .BR CLONE_UNTRACED " (since Linux 2.5.46)"
1285 .BR CLONE_UNTRACED " (Linux 2.5.46 °Ê¹ß)"
1286 .\"O If
1287 .\"O .B CLONE_UNTRACED
1288 .\"O is specified, then a tracing process cannot force
1289 .\"O .B CLONE_PTRACE
1290 .\"O on this child process.
1291 .B CLONE_UNTRACED
1292 ¤¬»ØÄꤵ¤ì¤ë¤È¡¢ trace ¤ò¹Ô¤Ã¤Æ¤¤¤ë¥×¥í¥»¥¹¤Ï
1293 ¤³¤Î»Ò¥×¥í¥»¥¹¤Ë
1294 .B CLONE_PTRACE
1295 ¤òŬÍѤ¹¤ë¤³¤È¤¬¤Ç¤­¤Ê¤¤¡£
1296 .TP
1297 .B CLONE_VFORK
1298 .\"O If
1299 .\"O .B CLONE_VFORK
1300 .\"O is set, the execution of the calling process is suspended
1301 .\"O until the child releases its virtual memory
1302 .\"O resources via a call to
1303 .\"O .BR execve (2)
1304 .\"O or
1305 .\"O .BR _exit (2)
1306 .\"O (as with
1307 .\"O .BR vfork (2)).
1308 .B CLONE_VFORK
1309 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢
1310 .RB ( vfork (2)
1311 ¤ÈƱÍͤË) »Ò¥×¥í¥»¥¹¤¬
1312 .BR execve (2)
1313 ¤Þ¤¿¤Ï
1314 .BR _exit (2)
1315 ¤Ë¤è¤Ã¤Æ²¾ÁÛ¥á¥â¥ê¤ò²òÊü¤¹¤ë¤Þ¤Ç¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î¼Â¹Ô¤ÏÄä»ß¤µ¤ì¤ë¡£
1316
1317 .\"O If
1318 .\"O .B CLONE_VFORK
1319 .\"O is not set then both the calling process and the child are schedulable
1320 .\"O after the call, and an application should not rely on execution occurring
1321 .\"O in any particular order.
1322 .B CLONE_VFORK
1323 ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢
1324 .BR clone ()
1325 ¸Æ¤Ó½Ð¤·¸å¤Ï¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤È»Ò¥×¥í¥»¥¹¤Î
1326 ξÊý¤¬¥¹¥±¥¸¥å¡¼¥ëÂоݤȤʤꡢ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï¤³¤ì¤é¤Î¥×¥í¥»¥¹¤Î
1327 ¼Â¹Ô½ç½ø¤Ë°Í¸¤·¤Ê¤¤¤è¤¦¤Ë¤¹¤Ù¤­¤Ç¤¢¤ë¡£
1328 .TP
1329 .B CLONE_VM
1330 .\"O If
1331 .\"O .B CLONE_VM
1332 .\"O is set, the calling process and the child process run in the same memory
1333 .\"O space.
1334 .\"O In particular, memory writes performed by the calling process
1335 .\"O or by the child process are also visible in the other process.
1336 .\"O Moreover, any memory mapping or unmapping performed with
1337 .\"O .BR mmap (2)
1338 .\"O or
1339 .\"O .BR munmap (2)
1340 .\"O by the child or calling process also affects the other process.
1341 .B CLONE_VM
1342 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤È»Ò¥×¥í¥»¥¹¤ÏƱ¤¸¥á¥â¥ê¶õ´Ö¤Ç
1343 ¼Â¹Ô¤µ¤ì¤ë¡£Æäˡ¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ä»Ò¥×¥í¥»¥¹¤Î°ìÊý¤¬¥á¥â¥ê¤Ë
1344 ½ñ¤­¹þ¤ó¤ÀÆâÍƤϤ⤦°ìÊý¤Î¥×¥í¥»¥¹¤«¤é¤â¸«¤ë¤³¤È¤¬¤Ç¤­¤ë¡£¤µ¤é¤Ë¡¢
1345 »Ò¥×¥í¥»¥¹¤ä¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î°ìÊý¤¬
1346 .BR mmap (2)
1347 ¤ä
1348 .BR munmap (2)
1349 ¤ò»È¤Ã¤Æ¥á¥â¥ê¤ò¥Þ¥Ã¥×¤·¤¿¤ê¥¢¥ó¥Þ¥Ã¥×¤·¤¿¾ì¹ç¡¢
1350 ¤â¤¦°ìÊý¤Î¥×¥í¥»¥¹¤Ë¤â±Æ¶Á¤¬µÚ¤Ö¡£
1351
1352 .\"O If
1353 .\"O .B CLONE_VM
1354 .\"O is not set, the child process runs in a separate copy of the memory
1355 .\"O space of the calling process at the time of
1356 .\"O .BR clone ().
1357 .\"O Memory writes or file mappings/unmappings performed by one of the
1358 .\"O processes do not affect the other, as with
1359 .\"O .BR fork (2).
1360 .B CLONE_VM
1361 ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢»Ò¥×¥í¥»¥¹¤Ï
1362 .BR clone ()
1363 ¤¬¼Â¹Ô¤µ¤ì¤¿»þÅÀ¤Ç¤Î¡¢¿Æ¥×¥í¥»¥¹¤Î¥á¥â¥ê¶õ´Ö¤ò¥³¥Ô¡¼¤·¤¿
1364 Ê̤Υá¥â¥ê¶õ´Ö¤Ç¼Â¹Ô¤µ¤ì¤ë¡£
1365 °ìÊý¤Î¥×¥í¥»¥¹¤¬¹Ô¤Ã¤¿¥á¥â¥ê¤Ø¤Î½ñ¤­¹þ¤ß¤ä
1366 ¥Õ¥¡¥¤¥ë¤Î¥Þ¥Ã¥×/¥¢¥ó¥Þ¥Ã¥×¤Ï¡¢
1367 .BR fork (2)
1368 ¤Î¾ì¹ç¤ÈƱÍÍ¡¢¤â¤¦°ìÊý¤Î¥×¥í¥»¥¹¤Ë¤Ï±Æ¶Á¤·¤Ê¤¤¡£
1369 .SS "sys_clone"
1370 .\"O The
1371 .\"O .B sys_clone
1372 .\"O system call corresponds more closely to
1373 .\"O .BR fork (2)
1374 .\"O in that execution in the child continues from the point of the
1375 .\"O call.
1376 .\"O Thus,
1377 .\"O .B sys_clone
1378 .\"O only requires the
1379 .\"O .I flags
1380 .\"O and
1381 .\"O .I child_stack
1382 .\"O arguments, which have the same meaning as for
1383 .\"O .BR clone ().
1384 .\"O (Note that the order of these arguments differs from
1385 .\"O .BR clone ().)
1386 .B sys_clone
1387 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï¡¢¤è¤ê
1388 .BR fork (2)
1389 ¤Ë¶á¤¤¤«¤¿¤Á¤Ë¤Ê¤Ã¤Æ¤ª¤ê¡¢»Ò¥×¥í¥»¥¹¤Î¼Â¹Ô¤¬¸Æ¤Ó½Ð¤·¤¬¹Ô¤ï¤ì¤¿¾ì½ê¤«¤é
1390 ³¤±¤é¤ì¤ë¡£
1391 ¤½¤Î¤¿¤á¡¢
1392 .B sys_clone
1393 ¤¬É¬ÍפȤ¹¤ë°ú¤­¿ô¤Ï
1394 .I flags
1395 ¤È
1396 .I child_stack
1397 ¤À¤±¤Ç¤¢¤ê¡¢¤½¤ì¤é¤Ï
1398 .BR clone ()
1399 ¤ÈƱ¤¸°ÕÌ£¤ò»ý¤Ä
1400 (¤³¤ì¤é¤Î°ú¤­¿ô¤Î½çÈÖ¤Ï
1401 .BR clone ()
1402 ¤È¤Ï°Û¤Ê¤ë¤³¤È¤ËÃí°Õ¤»¤è)¡£
1403
1404 .\"O Another difference for
1405 .\"O .B sys_clone
1406 .\"O is that the
1407 .\"O .I child_stack
1408 .\"O argument may be zero, in which case copy-on-write semantics ensure that the
1409 .\"O child gets separate copies of stack pages when either process modifies
1410 .\"O the stack.
1411 .\"O In this case, for correct operation, the
1412 .\"O .B CLONE_VM
1413 .\"O option should not be specified.
1414 .B sys_clone
1415 ¤Î¤â¤¦°ì¤Ä¤Î°ã¤¤¤Ï¡¢
1416 .I child_stack
1417 °ú¤­¿ô¤¬¥¼¥í¤Ç¤âÎɤ¤¤³¤È¤Ç¤¢¤ë¡£¤³¤Î¾ì¹ç¤Ë¤Ï¡¢¤É¤Á¤é¤«¤Î¥×¥í¥»¥¹¤¬
1418 ¥¹¥¿¥Ã¥¯¤òÊѹ¹¤·¤¿»þ¤Ë¡¢½ñ¤­¹þ¤ß»þ¥³¥Ô¡¼ (copy-on-write) Êý¼°¤Ë¤è¤ê
1419 »Ò¥×¥í¥»¥¹¤¬¥¹¥¿¥Ã¥¯¡¦¥Ú¡¼¥¸¤ÎÆÈΩ¤·¤¿¥³¥Ô¡¼¤òÆÀ¤é¤ì¤ë¤³¤È¤¬Êݾڤµ¤ì¤ë¡£
1420 ¤³¤Î¾ì¹ç¡¢Àµ¾ï¤ËÆ°ºî¤µ¤»¤ë¤¿¤á¤Ë¤Ï¡¢
1421 .B CLONE_VM
1422 ¥ª¥×¥·¥ç¥ó¤ò»ØÄꤷ¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
1423
1424 .\"O In Linux 2.4 and earlier,
1425 .\"O .BR clone ()
1426 .\"O does not take arguments
1427 .\"O .IR ptid ,
1428 .\"O .IR tls ,
1429 .\"O and
1430 .\"O .IR ctid .
1431 Linux 2.4 °ÊÁ°¤Ç¤Ï¡¢
1432 .BR clone ()
1433 ¤Ï°ú¤­¿ô
1434 .IR ptid ,
1435 .IR tls ,
1436 .IR ctid
1437 ¤ò¼è¤é¤Ê¤¤¡£
1438 .\"O .SH "RETURN VALUE"
1439 .SH ÊÖ¤êÃÍ
1440 .\"O .\" gettid(2) returns current->pid;
1441 .\"O .\" getpid(2) returns current->tgid;
1442 .\"O On success, the thread ID of the child process is returned
1443 .\"O in the caller's thread of execution.
1444 .\"O On failure, \-1 is returned
1445 .\"O in the caller's context, no child process will be created, and
1446 .\"O .I errno
1447 .\"O will be set appropriately.
1448 .\" gettid(2) ¤Ï current->pid ¤òÊÖ¤¹
1449 .\" getpid(2) ¤Ï current->tgid ¤òÊÖ¤¹
1450 À®¸ù¤·¤¿¾ì¹ç¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¼Â¹Ô¥¹¥ì¥Ã¥É¤Ë¤Ï»Ò¥×¥í¥»¥¹¤Î¥¹¥ì¥Ã¥ÉID ¤¬ÊÖ¤µ¤ì¤ë¡£
1451 ¼ºÇÔ¤·¤¿¾ì¹ç¡¢ ¸Æ¤Ó½Ð¤·¸µ¤Î¥³¥ó¥Æ¥­¥¹¥È¤Ë¤Ï \-1 ¤¬ÊÖ¤µ¤ì¡¢»Ò¥×¥í¥»¥¹¤Ï
1452 ºîÀ®¤µ¤ì¤º¡¢
1453 .I errno
1454 ¤¬Å¬ÀÚ¤ËÀßÄꤵ¤ì¤ë¡£
1455 .\"O .SH ERRORS
1456 .SH ¥¨¥é¡¼
1457 .TP
1458 .B EAGAIN
1459 .\"O Too many processes are already running.
1460 ¤¹¤Ç¤Ë¼Â¹ÔÃæ¤Î¥×¥í¥»¥¹¤¬Â¿¤¹¤®¤ë¡£
1461 .TP
1462 .B EINVAL
1463 .\"O .B CLONE_SIGHAND
1464 .\"O was specified, but
1465 .\"O .B CLONE_VM
1466 .\"O was not.
1467 .\"O (Since Linux 2.6.0-test6.)
1468 .B CLONE_SIGHAND
1469 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤¿¤¬¡¢
1470 .B CLONE_VM
1471 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤«¤Ã¤¿¡£
1472 (Linux 2.6.0-test6 °Ê¹ß)
1473 .TP
1474 .B EINVAL
1475 .\"O .B CLONE_THREAD
1476 .\"O was specified, but
1477 .\"O .B CLONE_SIGHAND
1478 .\"O was not.
1479 .\"O (Since Linux 2.5.35.)
1480 .B CLONE_THREAD
1481 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤¿¤¬¡¢
1482 .B CLONE_SIGHAND
1483 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤«¤Ã¤¿¡£
1484 (Linux 2.5.35 °Ê¹ß)
1485 .\" .TP
1486 .\" .B EINVAL
1487 .\"O .\" Precisely one of
1488 .\"O .\" .B CLONE_DETACHED
1489 .\"O .\" and
1490 .\"O .\" .B CLONE_THREAD
1491 .\"O .\" was specified.
1492 .\"O .\" (Since Linux 2.6.0-test6.)
1493 .\" .B CLONE_DETACHED
1494 .\" ¤È
1495 .\" .B CLONE_THREAD
1496 .\" ¤Î¤¤¤º¤ì¤«°ìÊý¤À¤±¤¬»ØÄꤵ¤ì¤¿¡£
1497 .\" (Linux 2.6.0-test6 °Ê¹ß)
1498 .TP
1499 .B EINVAL
1500 .\"O Both
1501 .\"O .B CLONE_FS
1502 .\"O and
1503 .\"O .B CLONE_NEWNS
1504 .\"O were specified in
1505 .\"O .IR flags .
1506 .B CLONE_FS
1507 ¤È
1508 .B CLONE_NEWNS
1509 ¤ÎξÊý¤¬
1510 .I flags
1511 ¤Ë»ØÄꤵ¤ì¤¿¡£
1512 .TP
1513 .B EINVAL
1514 .\"O Both
1515 .\"O .B CLONE_NEWIPC
1516 .\"O and
1517 .\"O .B CLONE_SYSVSEM
1518 .\"O were specified in
1519 .\"O .IR flags .
1520 .B CLONE_NEWIPC
1521 ¤È
1522 .B CLONE_SYSVSEM
1523 ¤ÎξÊý¤¬
1524 .I flags
1525 ¤Ë»ØÄꤵ¤ì¤¿¡£
1526 .TP
1527 .B EINVAL
1528 .\"O Both
1529 .\"O .BR CLONE_NEWPID
1530 .\"O and
1531 .\"O .BR CLONE_THREAD
1532 .\"O were specified in
1533 .\"O .IR flags .
1534 .B CLONE_NEWPID
1535 ¤È
1536 .B CLONE_THREAD
1537 ¤ÎξÊý¤¬
1538 .I flags
1539 ¤Ë»ØÄꤵ¤ì¤¿¡£
1540 .TP
1541 .B EINVAL
1542 .\"O Returned by
1543 .\"O .BR clone ()
1544 .\"O when a zero value is specified for
1545 .\"O .IR child_stack .
1546 .I child_stack
1547 ¤Ë¥¼¥í¤ò»ØÄꤷ¤¿¾ì¹ç¤Ë
1548 .BR clone ()
1549 ¤¬ÊÖ¤¹¡£
1550 .TP
1551 .B EINVAL
1552 .\"O .BR CLONE_NEWIPC
1553 .\"O was specified in
1554 .\"O .IR flags ,
1555 .\"O but the kernel was not configured with the
1556 .\"O .B CONFIG_SYSVIPC
1557 .\"O and
1558 .\"O .BR CONFIG_IPC_NS
1559 .\"O options.
1560 .I flags
1561 ¤Ë
1562 .B CLONE_NEWIPC
1563 ¤¬»ØÄꤵ¤ì¤¿¤¬¡¢¥«¡¼¥Í¥ë¤Ç¥ª¥×¥·¥ç¥ó
1564 .B CONFIG_SYSVIPC
1565 ¤È
1566 .B CONFIG_IPC_NS
1567 ¤¬Í­¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤Ê¤«¤Ã¤¿¡£
1568 .TP
1569 .B EINVAL
1570 .\"O .BR CLONE_NEWNET
1571 .\"O was specified in
1572 .\"O .IR flags ,
1573 .\"O but the kernel was not configured with the
1574 .\"O .B CONFIG_NET_NS
1575 .\"O option.
1576 .I flags
1577 ¤Ë
1578 .B CLONE_NEWNET
1579 ¤¬»ØÄꤵ¤ì¤¿¤¬¡¢¥«¡¼¥Í¥ë¤Ç¥ª¥×¥·¥ç¥ó
1580 .B CONFIG_NET_NS
1581 ¤¬Í­¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤Ê¤«¤Ã¤¿¡£
1582 .TP
1583 .B EINVAL
1584 .\"O .BR CLONE_NEWPID
1585 .\"O was specified in
1586 .\"O .IR flags ,
1587 .\"O but the kernel was not configured with the
1588 .\"O .B CONFIG_PID_NS
1589 .\"O option.
1590 .I flags
1591 ¤Ë
1592 .B CLONE_NEWPID
1593 ¤¬»ØÄꤵ¤ì¤¿¤¬¡¢¥«¡¼¥Í¥ë¤Ç¥ª¥×¥·¥ç¥ó
1594 .B CONFIG_PID_NS
1595 ¤¬Í­¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤Ê¤«¤Ã¤¿¡£
1596 .TP
1597 .B EINVAL
1598 .\"O .BR CLONE_NEWUTS
1599 .\"O was specified in
1600 .\"O .IR flags ,
1601 .\"O but the kernel was not configured with the
1602 .\"O .B CONFIG_UTS
1603 .\"O option.
1604 .I flags
1605 ¤Ë
1606 .B CLONE_NEWUTS
1607 ¤¬»ØÄꤵ¤ì¤¿¤¬¡¢¥«¡¼¥Í¥ë¤Ç¥ª¥×¥·¥ç¥ó
1608 .B CONFIG_UTS
1609 ¤¬Í­¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤Ê¤«¤Ã¤¿¡£
1610 .TP
1611 .B ENOMEM
1612 .\"O Cannot allocate sufficient memory to allocate a task structure for the
1613 .\"O child, or to copy those parts of the caller's context that need to be
1614 .\"O copied.
1615 »Ò¥×¥í¥»¥¹¤Î¤¿¤á¤Ë³ÎÊݤ¹¤Ù¤­¥¿¥¹¥¯¹½Â¤ÂΤ䡢¸Æ¤Ó½Ð¤·¸µ¤Î¥³¥ó¥Æ¥­¥¹¥È¤Î
1616 °ìÉô¤ò¥³¥Ô¡¼¤¹¤ë¤Î¤ËɬÍפʥá¥â¥ê¤ò½½Ê¬¤Ë³ä¤êÅö¤Æ¤ë¤³¤È¤¬¤Ç¤­¤Ê¤¤¡£
1617 .TP
1618 .B EPERM
1619 .\"O .BR CLONE_NEWIPC ,
1620 .\"O .BR CLONE_NEWNET ,
1621 .\"O .BR CLONE_NEWNS ,
1622 .\"O .BR CLONE_NEWPID ,
1623 .\"O or
1624 .\"O .BR CLONE_NEWUTS
1625 .\"O was specified by an unprivileged process (process without \fBCAP_SYS_ADMIN\fP).
1626 ÈóÆø¢¥×¥í¥»¥¹ (\fBCAP_SYS_ADMIN\fP ¤ò»ý¤¿¤Ê¤¤¥×¥í¥»¥¹) ¤¬
1627 .BR CLONE_NEWIPC ,
1628 .BR CLONE_NEWNET ,
1629 .BR CLONE_NEWNS ,
1630 .BR CLONE_NEWPID ,
1631 .BR CLONE_NEWUTS
1632 ¤ò»ØÄꤷ¤¿¡£
1633 .TP
1634 .B EPERM
1635 .\"O .B CLONE_PID
1636 .\"O was specified by a process other than process 0.
1637 PID ¤¬ 0 °Ê³°¤Î¥×¥í¥»¥¹¤Ë¤è¤Ã¤Æ
1638 .B CLONE_PID
1639 ¤¬»ØÄꤵ¤ì¤¿¡£
1640 .\"O .SH VERSIONS
1641 .SH ¥Ð¡¼¥¸¥ç¥ó
1642 .\"O There is no entry for
1643 .\"O .BR clone ()
1644 .\"O in libc5.
1645 .\"O glibc2 provides
1646 .\"O .BR clone ()
1647 .\"O as described in this manual page.
1648 libc5 ¤Ë¤Ï
1649 .BR clone ()
1650 ¤Ï¤Ê¤¤¡£glibc2 ¤Ç¤Ï
1651 .BR clone ()
1652 ¤¬Ä󶡤µ¤ì¤Æ¤ª¤ê¡¢¤³¤Î¥Þ¥Ë¥å¥¢¥ë¥Ú¡¼¥¸¤Ëµ­ºÜ¤ÎÄ̤ê¤Ç¤¢¤ë¡£
1653 .\"O .SH "CONFORMING TO"
1654 .SH ½àµò
1655 .\"O The
1656 .\"O .BR clone ()
1657 .\"O and
1658 .\"O .B sys_clone
1659 .\"O calls are Linux-specific and should not be used in programs
1660 .\"O intended to be portable.
1661 .BR clone ()
1662 ¤È
1663 .B sys_clone
1664 ¥³¡¼¥ë¤Ï Linux ÆÃÍ­¤Ç¤¢¤ê¡¢°Ü¿¢¤ò¹Íθ¤·¤¿¥×¥í¥°¥é¥à¤Ç¤Ï»ÈÍѤ¹¤Ù¤­
1665 ¤Ç¤Ï¤Ê¤¤¡£
1666 .\"O .SH NOTES
1667 .SH Ãí°Õ
1668 .\"O In the kernel 2.4.x series,
1669 .\"O .B CLONE_THREAD
1670 .\"O generally does not make the parent of the new thread the same
1671 .\"O as the parent of the calling process.
1672 .\"O However, for kernel versions 2.4.7 to 2.4.18 the
1673 .\"O .B CLONE_THREAD
1674 .\"O flag implied the
1675 .\"O .B CLONE_PARENT
1676 .\"O flag (as in kernel 2.6).
1677 ¥«¡¼¥Í¥ë 2.4.x ·ÏÎó¤Ç¤Ï¡¢°ìÈÌŪ¤Ë¤Ï
1678 .B CLONE_THREAD
1679 ¥Õ¥é¥°¤ò»ØÄꤷ¤Æ¤â¿·¤·¤¤¥¹¥ì¥Ã¥É¤Î¿Æ¤ò
1680 ¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Î¿Æ¤ÈƱ¤¸¤Ë¤Ï¤·¤Ê¤¤¡£
1681 ¤·¤«¤·¡¢¥Ð¡¼¥¸¥ç¥ó 2.4.7¡Á2.4.18 ¤Î¥«¡¼¥Í¥ë¤Ç¤Ï¡¢
1682 (¥«¡¼¥Í¥ë 2.6 ¤ÈƱ¤¸¤è¤¦¤Ë) CLONE_THREAD ¥Õ¥é¥°¤ò»ØÄꤹ¤ë¤È¡¢
1683 °ÅÌۤΤ¦¤Á¤Ë CLONE_PARENT ¥Õ¥é¥°¤ò»ØÄꤷ¤¿¤³¤È¤Ë¤Ê¤ë¡£
1684
1685 .\"O For a while there was
1686 .\"O .B CLONE_DETACHED
1687 .\"O (introduced in 2.5.32):
1688 .\"O parent wants no child-exit signal.
1689 .\"O In 2.6.2 the need to give this
1690 .\"O together with
1691 .\"O .B CLONE_THREAD
1692 .\"O disappeared.
1693 .\"O This flag is still defined, but has no effect.
1694 .B CLONE_DETACHED
1695 ¤È¤¤¤¦¥Õ¥é¥°¤¬¡¢2.5.32 ¤ÇƳÆþ¤µ¤ì¤Æ°ÊÍ褷¤Ð¤é¤¯¤Î´Ö¸ºß¤·¤¿¡£
1696 ¤³¤Î¥Õ¥é¥°¤Ï¿Æ¥×¥í¥»¥¹¤¬»Ò¥×¥í¥»¥¹½ªÎ»¤Î¥·¥°¥Ê¥ë¤òɬÍפȤ·¤Ê¤¤¤³¤È¤ò
1697 ɽ¤¹¤â¤Î¤Ç¤¢¤ë¡£
1698 2.6.2 ¤Ç¡¢ CLONE_DETATCHED ¤ò CLONE_THREAD ¤È°ì½ï¤Ë»ØÄꤹ¤ëɬÍפϤʤ¯¤Ê¤Ã¤¿¡£
1699 ¤³¤Î¥Õ¥é¥°¤Ï¤Þ¤ÀÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤¬¡¢²¿¤Î¸ú²Ì¤â¤Ê¤¤¡£
1700
1701 .\"O On i386,
1702 .\"O .BR clone ()
1703 .\"O should not be called through vsyscall, but directly through
1704 .\"O .IR "int $0x80" .
1705 i386 ¾å¤Ç¤Ï¡¢
1706 .BR clone ()
1707 ¤Ï vsyscall ·Ðͳ¤Ç¤Ï¤Ê¤¯¡¢Ä¾ÀÜ
1708 .I "int $0x80"
1709 ·Ðͳ¤Ç¸Æ¤Ó½Ð¤¹¤Ù¤­¤Ç¤¢¤ë¡£
1710
1711 .\"O On ia64, a different system call is used:
1712 ia64 ¤Ç¤Ï¡¢Ê̤Υ·¥¹¥Æ¥à¥³¡¼¥ë¤¬»ÈÍѤµ¤ì¤ë:
1713 .nf
1714
1715 .BI "int __clone2(int (*" "fn" ")(void *), "
1716 .BI "             void *" child_stack_base ", size_t " stack_size ,
1717 .BI "             int " flags ", void *" "arg" ", ... "
1718 .BI "          /* pid_t *" ptid ", struct user_desc *" tls \
1719 ", pid_t *" ctid " */ );"
1720 .fi
1721 .PP
1722 .\"O The
1723 .\"O .BR __clone2 ()
1724 .\"O system call operates in the same way as
1725 .\"O .BR clone (),
1726 .\"O except that
1727 .\"O .I child_stack_base
1728 .\"O points to the lowest address of the child's stack area,
1729 .\"O and
1730 .\"O .I stack_size
1731 .\"O specifies the size of the stack pointed to by
1732 .\"O .IR child_stack_base .
1733 .BR __clone2 ()
1734 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï
1735 .BR clone ()
1736 ¤ÈƱ¤¸¤è¤¦¤ËÆ°ºî¤¹¤ë¤¬¡¢°Ê²¼¤ÎÅÀ¤¬°Û¤Ê¤ë:
1737 .I child_stack_base
1738 ¤Ï»Ò¥×¥í¥»¥¹¤Î¥¹¥¿¥Ã¥¯¥¨¥ê¥¢¤ÎºÇ¾®¤Î¥¢¥É¥ì¥¹¤ò»Ø¤·¡¢
1739 .I stack_size
1740 ¤Ï
1741 .I child_stack_base
1742 ¤¬»Ø¤·¼¨¤¹¥¹¥¿¥Ã¥¯¥¨¥ê¥¢¤ÎÂ礭¤µ¤ò¼¨¤¹¡£
1743 .\"O .SH BUGS
1744 .SH ¥Ð¥°
1745 .\"O Versions of the GNU C library that include the NPTL threading library
1746 .\"O contain a wrapper function for
1747 .\"O .BR getpid (2)
1748 .\"O that performs caching of PIDs.
1749 NPTL ¥¹¥ì¥Ã¥É¡¦¥é¥¤¥Ö¥é¥ê¤ò´Þ¤ó¤Ç¤¤¤ë GNU C ¥é¥¤¥Ö¥é¥ê¤Î¤¤¤¯¤Ä¤«¤Î¥Ð¡¼¥¸¥ç¥ó
1750 ¤Ë¤Ï¡¢
1751 .BR getpid (2)
1752 ¤Î¥é¥Ã¥Ñ¡¼´Ø¿ô¤¬´Þ¤Þ¤ì¤Æ¤ª¤ê¡¢¤³¤Î¥é¥Ã¥Ñ¡¼´Ø¿ô¤Ï PID ¤ò¥­¥ã¥Ã¥·¥å¤¹¤ë¡£
1753 .\"O This caching relies on support in the glibc wrapper for
1754 .\"O .BR clone (),
1755 .\"O but as currently implemented,
1756 .\"O the cache may not be up to date in some circumstances.
1757 ¤³¤Î¥­¥ã¥Ã¥·¥å½èÍý¤¬Àµ¤·¤¯Æ°ºî¤¹¤ë¤¿¤á¤Ë¤Ï glibc ¤Î
1758 .BR clone ()
1759 ¤Î¥é¥Ã¥Ñ¡¼´Ø¿ô¤Ç¤Î½õ¤±¤¬É¬ÍפÀ¤¬¡¢¸½¾õ¤Î¼ÂÁõ¤Ç¤Ï¡¢
1760 ¤¢¤ë¾õ¶·²¼¤Ë¤ª¤¤¤Æ¥­¥ã¥Ã¥·¥å¤¬ºÇ¿·¤È¤Ê¤é¤Ê¤¤²ÄǽÀ­¤¬¤¢¤ë¡£
1761 .\"O In particular,
1762 .\"O if a signal is delivered to the child immediately after the
1763 .\"O .BR clone ()
1764 .\"O call, then a call to
1765 .\"O .BR getpid (2)
1766 .\"O in a handler for the signal may return the PID
1767 .\"O of the calling process ("the parent"),
1768 .\"O if the clone wrapper has not yet had a chance to update the PID
1769 .\"O cache in the child.
1770 Æäˡ¢
1771 .BR clone ()
1772 ¤Î¸Æ¤Ó½Ð¤·Ä¾¸å¤Ë¥·¥°¥Ê¥ë¤¬»Ò¥×¥í¥»¥¹¤ËÇÛÁ÷¤µ¤ì¤¿¾ì¹ç¤Ë¡¢
1773 ¤½¤Î¥·¥°¥Ê¥ë¤ËÂФ¹¤ë¥Ï¥ó¥É¥éÆâ¤Ç
1774 .BR getpid (2)
1775 ¤ò¸Æ¤Ó½Ð¤¹¤È¡¢¤½¤ì¤Þ¤Ç¤Ë clone ¤Î¥é¥Ã¥Ñ¡¼´Ø¿ô¤¬»Ò¥×¥í¥»¥¹¤Î PID ¥­¥ã¥Ã¥·¥å¤ò
1776 ¹¹¿·¤¹¤ëµ¡²ñ¤¬ÆÀ¤é¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹ ("¿Æ¥×¥í¥»¥¹") ¤Î PID ¤¬
1777 ÊÖ¤µ¤ì¤ë²ÄǽÀ­¤¬¤¢¤ë¡£
1778 .\"O (This discussion ignores the case where the child was created using
1779 .\"O .BR CLONE_THREAD ,
1780 .\"O when
1781 .\"O .BR getpid (2)
1782 .\"O .I should
1783 .\"O return the same value in the child and in the process that called
1784 .\"O .BR clone (),
1785 .\"O since the caller and the child are in the same thread group.
1786 .\"O The stale-cache problem also does not occur if the
1787 .\"O .I flags
1788 .\"O argument includes
1789 .\"O .BR CLONE_VM .)
1790 (¤³¤ÎµÄÏÀ¤Ç¤Ï¡¢»Ò¥×¥í¥»¥¹¤¬
1791 .B CLONE_THREAD
1792 ¤ò»È¤Ã¤ÆºîÀ®¤µ¤ì¤¿¾ì¹ç¤Î¤³¤È¤Ï̵»ë¤·¤Æ¤¤¤ë¡£
1793 »Ò¥×¥í¥»¥¹¤¬
1794 .B CLONE_THREAD
1795 ¤òºî¤Ã¤ÆºîÀ®¤µ¤ì¤¿¾ì¹ç¤Ë¤Ï¡¢
1796 ¸Æ¤Ó½Ð¤·¸µ¤È»Ò¥×¥í¥»¥¹¤ÏƱ¤¸¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Ë°¤¹¤Î¤Ç¡¢
1797 .BR getpid (2)
1798 ¤Ï»Ò¥×¥í¥»¥¹¤È
1799 .BR clone ()
1800 ¤ò¸Æ¤Ó½Ð¤·¤¿¥×¥í¥»¥¹¤ÇƱ¤¸ÃͤòÊÖ¤¹¤Î¤¬¡ÖÀµ¤·¤¤¡×¡£
1801 ¥­¥ã¥Ã¥·¥å¤¬ºÇ¿·¤È¤Ê¤é¤Ê¤¤ÌäÂê (stale-cache problem) ¤Ï¡¢
1802 .I flags
1803 ¤Ë
1804 .B CLONE_VM
1805 ¤¬´Þ¤Þ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤âȯÀ¸¤·¤Ê¤¤¡£)
1806 .\"O To get the truth, it may be necessary to use code such as the following:
1807 ËÜÅö¤ÎÃͤòÆÀ¤ë¤¿¤á¤Ë¤Ï¡¢¼¡¤Î¤è¤¦¤Ê¥³¡¼¥É¤ò»È¤¦É¬Íפ¬¤¢¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
1808 .nf
1809
1810     #include <syscall.h>
1811
1812     pid_t mypid;
1813
1814     mypid = syscall(SYS_getpid);
1815 .fi
1816 .\" See also the following bug reports
1817 .\" https://bugzilla.redhat.com/show_bug.cgi?id=417521
1818 .\" http://sourceware.org/bugzilla/show_bug.cgi?id=6910
1819 .\"O .SH "SEE ALSO"
1820 .SH ´ØÏ¢¹àÌÜ
1821 .BR fork (2),
1822 .BR futex (2),
1823 .BR getpid (2),
1824 .BR gettid (2),
1825 .BR set_thread_area (2),
1826 .BR set_tid_address (2),
1827 .BR tkill (2),
1828 .BR unshare (2),
1829 .BR wait (2),
1830 .BR capabilities (7),
1831 .BR pthreads (7)