OSDN Git Service

(split) LDP v3.24 -> v3.29 の定型的な変更内容を反映。
[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-09-10 "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 is not yet complete,
517 .\"O but probably will be mostly complete by about Linux 2.6.28.)
518 (¤³¤Î¥Õ¥é¥°¤Î¼ÂÁõ¤Ï¤Þ¤À´°Î»¤·¤Æ¤¤¤Ê¤¤¤¬¡¢
519 ¤ª¤½¤é¤¯ Linux 2.6.28 ¤¢¤¿¤ê¤Þ¤Ç¤Ë¤Ï¤Û¤Ü´°À®¤¹¤ë¤³¤È¤À¤í¤¦¡£)
520
521 .\"O If
522 .\"O .B CLONE_NEWNET
523 .\"O is set, then create the process in a new network namespace.
524 .\"O If this flag is not set, then (as with
525 .\"O .BR fork (2)),
526 .\"O the process is created in the same network namespace as
527 .\"O the calling process.
528 .\"O This flag is intended for the implementation of containers.
529 .B CLONE_NEWNET
530 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢¿·¤·¤¤¥Í¥Ã¥È¥ï¡¼¥¯Ì¾Á°¶õ´Ö (network namaspace)
531 ¤Ç¥×¥í¥»¥¹¤òºîÀ®¤¹¤ë¡£
532 ¤³¤Î¥Õ¥é¥°¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢
533 .RB ( fork (2)
534 ¤Î¾ì¹ç¤ÈƱÍÍ) ¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ÈƱ¤¸¥Í¥Ã¥È¥ï¡¼¥¯Ì¾Á°¶õ´Ö¤Ç¥×¥í¥»¥¹¤¬
535 ºîÀ®¤µ¤ì¤ë¡£
536 ¤³¤Î¥Õ¥é¥°¤Ï¡¢¥³¥ó¥Æ¥Ê¤Î¼ÂÁõ¤Ç¤Î»ÈÍѤò°Õ¿Þ¤·¤ÆÍÑ°Õ¤µ¤ì¤¿¤â¤Î¤Ç¤¢¤ë¡£
537
538 .\"O A network namespace provides an isolated view of the networking stack
539 .\"O (network device interfaces, IPv4 and IPv6 protocol stacks,
540 .\"O IP routing tables, firewall rules, the
541 .\"O .I /proc/net
542 .\"O and
543 .\"O .I /sys/class/net
544 .\"O directory trees, sockets, etc.).
545 .\"O A physical network device can live in exactly one
546 .\"O network namespace.
547 .\"O A virtual network device ("veth") pair provides a pipe-like abstraction
548 .\"O that can be used to create tunnels between network namespaces,
549 .\"O and can be used to create a bridge to a physical network device
550 .\"O in another namespace.
551 ¥Í¥Ã¥È¥ï¡¼¥¯Ì¾Á°¶õ´Ö¤Ï¡¢Ê¬Î¥¤µ¤ì¤¿¥Í¥Ã¥È¥ï¡¼¥¯¥¹¥¿¥Ã¥¯¤òÄ󶡤¹¤ë¤â¤Î¤Ç¤¢¤ë
552 (¥Í¥Ã¥È¥ï¡¼¥¯¥¹¥¿¥Ã¥¯¤È¤Ï¡¢
553 ¥Í¥Ã¥È¥ï¡¼¥¯¥Ç¥Ð¥¤¥¹¥¤¥ó¥¿¥Õ¥§¡¼¥¹¡¢IPv4 ¤ä IPv6 ¥×¥í¥È¥³¥ë¥¹¥¿¥Ã¥¯¡¢
554 .IR /proc/net ¡¢
555 .I /sys/class/net
556 ¥Ç¥£¥ì¥¯¥È¥ê¥Ä¥ê¡¼¡¢¥½¥±¥Ã¥È¤Ê¤É¤Ç¤¢¤ë)¡£
557 ʪÍý¥Í¥Ã¥È¥ï¡¼¥¯¥Ç¥Ð¥¤¥¹¤¬½ê°¤Ç¤­¤ë¥Í¥Ã¥È¥ï¡¼¥¯Ì¾Á°¶õ´Ö¤Ï°ì¤Ä¤À¤±¤Ç¤¢¤ë¡£
558 ²¾Áۥͥåȥ¥¯¥Ç¥Ð¥¤¥¹ ("veth") ¤Î¥Ú¥¢¤Ë¤è¤ê
559 ¥Ñ¥¤¥×É÷¤ÎÃê¾Ý²½ (abstraction) ¤¬¼Â¸½¤µ¤ì¤Æ¤ª¤ê¡¢
560 ¤³¤ì¤ò»È¤¦¤³¤È¤Ç¡¢¥Í¥Ã¥È¥ï¡¼¥¯Ì¾Á°¶õ´Ö´Ö¤Î¥È¥ó¥Í¥ë¤òºîÀ®¤·¤¿¤ê¡¢
561 Ê̤Î̾Á°¶õ´Ö¤ÎʪÍý¥Í¥Ã¥È¥ï¡¼¥¯¥Ç¥Ð¥¤¥¹¤Ø¤Î¥Ö¥ê¥Ã¥¸¤òºîÀ®¤·¤¿¤ê
562 ¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
563
564 .\"O When a network namespace is freed
565 .\"O (i.e., when the last process in the namespace terminates),
566 .\"O its physical network devices are moved back to the
567 .\"O initial network namespace (not to the parent of the process).
568 ¥Í¥Ã¥È¥ï¡¼¥¯Ì¾Á°¶õ´Ö¤¬²òÊü¤µ¤ì¤ë»þ
569 (¤¹¤Ê¤ï¤Á¡¢¤½¤Î̾Á°¶õ´Ö¤ÎºÇ¸å¤Î¥×¥í¥»¥¹¤¬½ªÎ»¤¹¤ë»þ)¡¢
570 ʪÍý¥Í¥Ã¥È¥ï¡¼¥¯¥Ç¥Ð¥¤¥¹¤Ï½é´ü¥Í¥Ã¥È¥ï¡¼¥¯Ì¾Á°¶õ´Ö
571 (initial network namespace) ¤ËÌᤵ¤ì¤ë
572 (¿Æ¥×¥í¥»¥¹¤Î¥Í¥Ã¥È¥ï¡¼¥¯Ì¾Á°¶õ´Ö¤ËÌᤵ¤ì¤ëÌõ¤Ç¤Ï¤Ê¤¤)¡£
573
574 .\"O Use of this flag requires: a kernel configured with the
575 .\"O .B CONFIG_NET_NS
576 .\"O option and that the process be privileged
577 .\"O .RB ( CAP_SYS_ADMIN ).
578 ¤³¤Î¥Õ¥é¥°¤ò»ÈÍѤ¹¤ë¤¿¤á¤Ë¤Ï¡¢
579 ¥«¡¼¥Í¥ë¤Ç¥ª¥×¥·¥ç¥ó
580 .B CONFIG_NET_NS
581 ¤òÍ­¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤³¤È¡¢
582 ¥×¥í¥»¥¹¤¬Æø¢
583 .RB ( CAP_SYS_ADMIN )
584 ¤ò»ý¤Ã¤Æ¤¤¤ë¤³¤È¤¬É¬ÍפǤ¢¤ë¡£
585 .TP
586 .\"O .BR CLONE_NEWNS " (since Linux 2.4.19)"
587 .BR CLONE_NEWNS " (Linux 2.4.19 °Ê¹ß)"
588 .\"O Start the child in a new mount namespace.
589 »Ò¥×¥í¥»¥¹¤ò¿·¤·¤¤¥Þ¥¦¥ó¥È̾Á°¶õ´Ö (mount namespace) ¤Ç³«»Ï¤¹¤ë¡£
590
591 .\"O Every process lives in a mount namespace.
592 .\"O The
593 .\"O .I namespace
594 .\"O of a process is the data (the set of mounts) describing the file hierarchy
595 .\"O as seen by that process.
596 .\"O After a
597 .\"O .BR fork (2)
598 .\"O or
599 .\"O .BR clone ()
600 .\"O where the
601 .\"O .B CLONE_NEWNS
602 .\"O flag is not set, the child lives in the same mount
603 .\"O namespace as the parent.
604 ³Æ¥×¥í¥»¥¹¤Ï¤¢¤ë°ì¤Ä¤Î¥Þ¥¦¥ó¥È̾Á°¶õ´ÖÃæ¤Ë¸ºß¤¹¤ë¡£¥×¥í¥»¥¹¤Î
605 .I "̾Á°¶õ´Ö (namespace)"
606 ¤Ï¡¢¤½¤Î¥×¥í¥»¥¹¤«¤é¸«¤¨¤ë¥Õ¥¡¥¤¥ë³¬Áؤòɽ¤¹¥Ç¡¼¥¿ (mount ¤Î½¸¹ç) ¤Ç¤¢¤ë¡£
607 .B CLONE_NEWNS
608 ¥Õ¥é¥°¤¬¥»¥Ã¥È¤µ¤ì¤º¤Ë
609 .BR fork (2)
610 ¤«
611 .BR clone ()
612 ¤¬¸Æ¤Ð¤ì¤ë¤È¡¢»Ò¥×¥í¥»¥¹¤Ï¿Æ¥×¥í¥»¥¹¤ÈƱ¤¸¥Þ¥¦¥ó¥È̾Á°¶õ´Ö¤ËºîÀ®¤µ¤ì¤ë¡£
613 .\"O The system calls
614 .\"O .BR mount (2)
615 .\"O and
616 .\"O .BR umount (2)
617 .\"O change the mount namespace of the calling process, and hence affect
618 .\"O all processes that live in the same namespace, but do not affect
619 .\"O processes in a different mount namespace.
620 ¥·¥¹¥Æ¥à¥³¡¼¥ë
621 .BR mount (2)¡¢
622 .BR umount (2)
623 ¤¬¸Æ¤Ð¤ì¤ë¤È¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î¥Þ¥¦¥ó¥È̾Á°¶õ´Ö¤¬Êѹ¹¤µ¤ì¡¢¤³¤Î·ë²Ì
624 ¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ÈƱ¤¸Ì¾Á°¶õ´Ö¤Ë¤¤¤ë¥×¥í¥»¥¹¤Ï¤¹¤Ù¤Æ±Æ¶Á¤ò¼õ¤±¤ë¤¬¡¢
625 °Û¤Ê¤ë¥Þ¥¦¥ó¥È̾Á°¶õ´Ö¤Ë¤¤¤ë¥×¥í¥»¥¹¤Ï±Æ¶Á¤ò¼õ¤±¤Ê¤¤¡£
626
627 .\"O After a
628 .\"O .BR clone ()
629 .\"O where the
630 .\"O .B CLONE_NEWNS
631 .\"O flag is set, the cloned child is started in a new mount namespace,
632 .\"O initialized with a copy of the namespace of the parent.
633 .B CLONE_NEWNS
634 ¥Õ¥é¥°¤¬¥»¥Ã¥È¤µ¤ì¤Æ
635 .BR clone ()
636 ¤¬¸Æ¤Ð¤ì¤ë¤È¡¢clone ¤ÇºîÀ®¤µ¤ì¤¿»Ò¥×¥í¥»¥¹¤Ï¿·¤·¤¤¥Þ¥¦¥ó¥È̾Á°¶õ´Ö¤Ç
637 ³«»Ï¤µ¤ì¤ë¡£¿·¤·¤¤Ì¾Á°¶õ´Ö¤Ï¿Æ¥×¥í¥»¥¹¤Î̾Á°¶õ´Ö¤Î¥³¥Ô¡¼¤Ç½é´ü²½¤µ¤ì¤ë¡£
638
639 .\"O Only a privileged process (one having the \fBCAP_SYS_ADMIN\fP capability)
640 .\"O may specify the
641 .\"O .B CLONE_NEWNS
642 .\"O flag.
643 .\"O It is not permitted to specify both
644 .\"O .B CLONE_NEWNS
645 .\"O and
646 .\"O .B CLONE_FS
647 .\"O in the same
648 .\"O .BR clone ()
649 .\"O call.
650 Æø¢¥×¥í¥»¥¹ (\fBCAP_SYS_ADMIN\fP ¥±¡¼¥Ñ¥Ó¥ê¥Æ¥£¤ò»ý¤Ä¥×¥í¥»¥¹) ¤Î¤ß¤¬
651 .B CLONE_NEWNS
652 ¥Õ¥é¥°¤ò»ØÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
653 °ì¤Ä¤Î
654 .BR clone ()
655 ¸Æ¤Ó½Ð¤·¤Ç¡¢
656 .B CLONE_NEWNS
657 ¤È
658 .B CLONE_FS
659 ¤ÎξÊý¤ò»ØÄꤹ¤ë¤³¤È¤Ï¤Ç¤­¤Ê¤¤¡£
660 .TP
661 .\"O .BR CLONE_NEWPID " (since Linux 2.6.24)"
662 .BR CLONE_NEWPID " (Linux 2.6.24 °Ê¹ß)"
663 .\" This explanation draws a lot of details from
664 .\" http://lwn.net/Articles/259217/
665 .\" Authors: Pavel Emelyanov <xemul@openvz.org>
666 .\" and Kir Kolyshkin <kir@openvz.org>
667 .\"
668 .\" The primary kernel commit is 30e49c263e36341b60b735cbef5ca37912549264
669 .\" Author: Pavel Emelyanov <xemul@openvz.org>
670 .\"O If
671 .\"O .B CLONE_NEWPID
672 .\"O is set, then create the process in a new PID namespace.
673 .\"O If this flag is not set, then (as with
674 .\"O .BR fork (2)),
675 .\"O the process is created in the same PID namespace as
676 .\"O the calling process.
677 .\"O This flag is intended for the implementation of containers.
678 .B CLONE_NEWPID
679 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢¿·¤·¤¤ PID Ì¾Á°¶õ´Ö¤Ç¥×¥í¥»¥¹¤òºîÀ®¤¹¤ë¡£
680 ¤³¤Î¥Õ¥é¥°¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢
681 .RB ( fork (2)
682 ¤Î¾ì¹ç¤ÈƱÍÍ) ¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ÈƱ¤¸ PID Ì¾Á°¶õ´Ö¤Ç
683 ¥×¥í¥»¥¹¤¬ºîÀ®¤µ¤ì¤ë¡£
684 ¤³¤Î¥Õ¥é¥°¤Ï¡¢¥³¥ó¥Æ¥Ê¤Î¼ÂÁõ¤Ç¤Î»ÈÍѤò°Õ¿Þ¤·¤ÆÍÑ°Õ¤µ¤ì¤¿¤â¤Î¤Ç¤¢¤ë¡£
685
686 .\"O A PID namespace provides an isolated environment for PIDs:
687 .\"O PIDs in a new namespace start at 1,
688 .\"O somewhat like a standalone system, and calls to
689 .\"O .BR fork (2),
690 .\"O .BR vfork (2),
691 .\"O or
692 .\"O .BR clone (2)
693 .\"O will produce processes with PIDs that are unique within the namespace.
694 PID Ì¾Á°¶õ´Ö¤Ï¡¢PID ¤Ë´Ø¤·¤ÆʬΥ¤µ¤ì¤¿´Ä¶­¤òÄ󶡤¹¤ë¤â¤Î¤Ç¤¢¤ë¡£
695 ¿·¤·¤¤Ì¾Á°¶õ´Ö¤Ë¤ª¤±¤ë PID ¤Ï 1 ¤«¤é»Ï¤Þ¤ê
696 (¤³¤ì¤Ï¥¹¥¿¥ó¥É¥¢¥í¥ó¤Î¥·¥¹¥Æ¥à¤È»÷¤¿¤è¤¦¤Ê´¶¤¸)¡¢
697 .BR fork (2),
698 .BR vfork (2),
699 .BR clone (2)
700 ¤ò¸Æ¤Ó½Ð¤¹¤È¡¢¤½¤Î̾Á°¶õ´Ö¤Ç°ì°Õ¤Ê PID ¤ò»ý¤Ã¤¿¥×¥í¥»¥¹¤¬ºîÀ®¤µ¤ì¤ë¡£
701
702 .\"O The first process created in a new namespace
703 .\"O (i.e., the process created using the
704 .\"O .BR CLONE_NEWPID
705 .\"O flag) has the PID 1, and is the "init" process for the namespace.
706 .\"O Children that are orphaned within the namespace will be reparented
707 .\"O to this process rather than
708 .\"O .BR init (8).
709 .\"O Unlike the traditional
710 .\"O .B init
711 .\"O process, the "init" process of a PID namespace can terminate,
712 .\"O and if it does, all of the processes in the namespace are terminated.
713 ¿·¤·¤¤Ì¾Á°¶õ´Ö¤ÇºîÀ®¤µ¤ì¤ëºÇ½é¤Î¥×¥í¥»¥¹
714 (¤Ä¤Þ¤ê¡¢
715 .B CLONE_NEWPID
716 ¥Õ¥é¥°¤ò»È¤Ã¤ÆºîÀ®¤µ¤ì¤¿¥×¥í¥»¥¹) ¤Î PID ¤Ï 1 ¤Ç¤¢¤ê¡¢
717 ¤³¤Î¥×¥í¥»¥¹¤Ï¤½¤Î̾Á°¶õ´Ö¤Ë¤ª¤±¤ë "init" ¥×¥í¥»¥¹¤È¤Ê¤ë¡£
718 ¤³¤Î̾Á°¶õ´Ö¤Ë¤ª¤¤¤Æ¸É»ù (orphaned) ¤È¤Ê¤Ã¤¿»Ò¥×¥í¥»¥¹¤Ë¤Ä¤¤¤Æ¤Ï¡¢
719 .BR init (8)
720 ¤Ç¤Ï¤Ê¤¯¤³¤Î¥×¥í¥»¥¹¤¬¿Æ¥×¥í¥»¥¹¤È¤Ê¤ë¡£
721 ÀΤʤ¬¤é¤Î
722 .B init
723 ¥×¥í¥»¥¹¤È¤Ï°ã¤¤¡¢PID Ì¾Á°¶õ´Ö¤Î "init" ¥×¥í¥»¥¹¤Ï½ªÎ» (terminated) ¤¹¤ë
724 ¤³¤È¤¬¤Ç¤­¡¢¤½¤Î¾ì¹ç¤Ë¤Ï¡¢¤³¤Î̾Á°¶õ´Ö¤ÎÁ´¤Æ¤Î¥×¥í¥»¥¹¤¬½ªÎ»¤µ¤ì¤ë¡£
725
726 .\"O PID namespaces form a hierarchy.
727 PID Ì¾Á°¶õ´Ö´Ö¤Ë¤Ï³¬Áع½Â¤¤¬·ÁÀ®¤µ¤ì¤ë¡£
728 .\"O When a new PID namespace is created,
729 .\"O the processes in that namespace are visible
730 .\"O in the PID namespace of the process that created the new namespace;
731 .\"O analogously, if the parent PID namespace is itself
732 .\"O the child of another PID namespace,
733 .\"O then processes in the child and parent PID namespaces will both be
734 .\"O visible in the grandparent PID namespace.
735 ¿·¤·¤¤ PID Ì¾Á°¶õ´Ö¤¬ºîÀ®¤µ¤ì¤ë¤È¡¢¤½¤Î̾Á°¶õ´Ö¤Î¥×¥í¥»¥¹¤Ï¡¢
736 ¿·¤·¤¤Ì¾Á°¶õ´Ö¤òºîÀ®¤·¤¿¥×¥í¥»¥¹¤Î PID Ì¾Á°¶õ´Ö¤Ç¸«¤¨¤ë¡£
737 ƱÍͤˡ¢¿Æ¤Î PID Ì¾Á°¶õ´Ö¼«ÂΤ¬Ê̤ΠPID Ì¾Á°¶õ´Ö¤Î»Ò¶¡¤Î¾ì¹ç¤Ë¤Ï¡¢
738 »Ò¶¡¤Î PID Ì¾Á°¶õ´Ö¤È¿Æ¤Î PID Ì¾Á°¶õ´Ö¤Î¥×¥í¥»¥¹¤Ï¤É¤ì¤â
739 ¿Æ¤Î¿Æ¤Î PID Ì¾Á°¶õ´Ö¤Ç¤â¸«¤¨¤ë¤³¤È¤Ë¤Ê¤ë¡£
740 .\"O Conversely, the processes in the "child" PID namespace do not see
741 .\"O the processes in the parent namespace.
742 .\"O The existence of a namespace hierarchy means that each process
743 .\"O may now have multiple PIDs:
744 .\"O one for each namespace in which it is visible;
745 .\"O each of these PIDs is unique within the corresponding namespace.
746 .\"O (A call to
747 .\"O .BR getpid (2)
748 .\"O always returns the PID associated with the namespace in which
749 .\"O the process lives.)
750 È¿ÂФˡ¢¡Ö»Ò¶¡¡×¤Î PID Ì¾Á°¶õ´Ö¤Î¥×¥í¥»¥¹¤Ë¤Ï¡¢
751 ¿Æ¤Î̾Á°¶õ´Ö¤Î¥×¥í¥»¥¹¤Ï¸«¤¨¤Ê¤¤¡£
752 ̾Á°¶õ´Ö¤Ë³¬Áع½Â¤¤¬Â¸ºß¤¹¤ë¤È¤¤¤¦¤³¤È¤Ï¡¢¸Ä¡¹¤Î¥×¥í¥»¥¹¤Ï
753 Ê£¿ô¤Î PID ¤ò»ý¤Ä¤È¤¤¤¦¤³¤È¤ò°ÕÌ£¤·¤Æ¤¤¤ë¡£
754 ¤½¤Î¥×¥í¥»¥¹¤¬¸«¤¨¤ë̾Á°¶õ´Ö°ì¤Ä¤Ë¤Ä¤­ PID ¤¬°ì¤Ä¤¢¤ê¡¢
755 ¤½¤ì¤¾¤ì¤Î PID ¤ÏÂбþ¤¹¤ë̾Á°¶õ´Ö¤Ë¤ª¤¤¤Æ°ì°Õ¤Ç¤¢¤ë¡£
756 .RB ( getpid (2)
757 ¤ò¸Æ¤Ó½Ð¤¹¤È¡¢¾ï¤Ë¤½¤Î¥×¥í¥»¥¹¤¬Â¸ºß¤·¤Æ¤¤¤ë̾Á°¶õ´Ö¤Ë¤ª¤±¤ë
758 PID ¤¬ÊÖ¤µ¤ì¤ë¡£)
759
760 .\"O After creating the new namespace,
761 .\"O it is useful for the child to change its root directory
762 .\"O and mount a new procfs instance at
763 .\"O .I /proc
764 .\"O so that tools such as
765 .\"O .BR ps (1)
766 .\"O work correctly.
767 ¿·¤·¤¤Ì¾Á°¶õ´Ö¤ÎºîÀ®¸å¤Ë¤Ï¡¢
768 »Ò¥×¥í¥»¥¹¤Ë¤ª¤¤¤Æ¡¢
769 .BR ps (1)
770 ¤È¤¤¤Ã¤¿¥Ä¡¼¥ë¤¬Àµ¤·¤¯Æ°ºî¤¹¤ë¤è¤¦¤Ë¡¢
771 ¼«¿È¤Î root ¥Ç¥£¥ì¥¯¥È¥ê¤òÊѹ¹¤·¡¢
772 .I /proc
773 ¤Ë¿·¤·¤¤ procfs ¥¤¥ó¥¹¥¿¥ó¥¹¤ò¥Þ¥¦¥ó¥È¤¹¤ë¤Î¤¬¤è¤¤¤À¤í¤¦¡£
774 .\" mount -t proc proc /proc
775 .\"O (If
776 .\"O .BR CLONE_NEWNS
777 .\"O is also included in
778 .\"O .IR flags ,
779 .\"O then it isn't necessary to change the root directory:
780 .\"O a new procfs instance can be mounted directly over
781 .\"O .IR /proc .)
782 .RB ( flags
783 ¤Ë
784 .B CLONE_NEWNS
785 ¤â»ØÄꤵ¤ì¤Æ¤¤¤¿¾ì¹ç¤Ë¤Ï¡¢root ¥Ç¥£¥ì¥¯¥È¥ê¤òÊѹ¹¤¹¤ëɬÍפϤʤ¯¡¢
786 ¤¤¤­¤Ê¤ê¿·¤·¤¤ procfs ¥¤¥ó¥¹¥¿¥ó¥¹¤ò
787 .I /proc
788 ¤Ë¥Þ¥¦¥ó¥È¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£)
789
790 .\"O Use of this flag requires: a kernel configured with the
791 .\"O .B CONFIG_PID_NS
792 .\"O option and that the process be privileged
793 .\"O .RB ( CAP_SYS_ADMIN ).
794 .\"O This flag can't be specified in conjunction with
795 .\"O .BR CLONE_THREAD .
796 ¤³¤Î¥Õ¥é¥°¤ò»ÈÍѤ¹¤ë¤¿¤á¤Ë¤Ï¡¢
797 ¥«¡¼¥Í¥ë¤Ç¥ª¥×¥·¥ç¥ó
798 .B CONFIG_PID_NS
799 ¤òÍ­¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤³¤È¡¢
800 ¥×¥í¥»¥¹¤¬Æø¢
801 .RB ( CAP_SYS_ADMIN )
802 ¤ò»ý¤Ã¤Æ¤¤¤ë¤³¤È¤¬É¬ÍפǤ¢¤ë¡£
803 ¤³¤Î¥Õ¥é¥°¤Ï
804 .B CLONE_THREAD
805 ¤ÈÁȤ߹ç¤ï¤»¤Æ»È¤¦¤³¤È¤Ï¤Ç¤­¤Ê¤¤¡£
806 .TP
807 .\"O .BR CLONE_NEWUTS " (since Linux 2.6.19)"
808 .BR CLONE_NEWUTS " (Linux 2.6.19 °Ê¹ß)"
809 .\"O If
810 .\"O .B CLONE_NEWUTS
811 .\"O is set, then create the process in a new UTS namespace,
812 .\"O whose identifiers are initialized by duplicating the identifiers
813 .\"O from the UTS namespace of the calling process.
814 .\"O If this flag is not set, then (as with
815 .\"O .BR fork (2)),
816 .\"O the process is created in the same UTS namespace as
817 .\"O the calling process.
818 .\"O This flag is intended for the implementation of containers.
819 .B CLONE_NEWUTS
820 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢¿·¤·¤¤ UTS Ì¾Á°¶õ´Ö¤Ç¥×¥í¥»¥¹¤òºîÀ®¤¹¤ë¡£
821 ¿·¤·¤¤ UTS Ì¾Á°¶õ´Ö¤Î¼±Ê̻Ҥνé´üÃͤϡ¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î
822 UTS Ì¾Á°¶õ´Ö¤Î¼±Ê̻ҤòÊ£À½¤·¤¿¤â¤Î¤È¤Ê¤ë¡£
823 ¤³¤Î¥Õ¥é¥°¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢
824 .RB ( fork (2)
825 ¤Î¾ì¹ç¤ÈƱÍÍ) ¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ÈƱ¤¸ UTS Ì¾Á°¶õ´Ö¤Ç
826 ¥×¥í¥»¥¹¤¬ºîÀ®¤µ¤ì¤ë¡£
827 ¤³¤Î¥Õ¥é¥°¤Ï¡¢¥³¥ó¥Æ¥Ê¤Î¼ÂÁõ¤Ç¤Î»ÈÍѤò°Õ¿Þ¤·¤ÆÍÑ°Õ¤µ¤ì¤¿¤â¤Î¤Ç¤¢¤ë¡£
828
829 .\"O A UTS namespace is the set of identifiers returned by
830 .\"O .BR uname (2);
831 .\"O among these, the domain name and the host name can be modified by
832 .\"O .BR setdomainname (2)
833 .\"O and
834 .\"O .BR
835 .\"O .BR sethostname (2),
836 .\"O respectively.
837 .\"O Changes made to the identifiers in a UTS namespace
838 .\"O are visible to all other processes in the same namespace,
839 .\"O but are not visible to processes in other UTS namespaces.
840 UTS Ì¾Á°¶õ´Ö¤Ï¡¢
841 .BR uname (2)
842 ¤¬ÊÖ¤¹¼±Ê̻Ҥν¸¹ç¤Ç¤¢¤ë¡£
843 ¼±Ê̻ҤȤ·¤Æ¤Ï¥É¥á¥¤¥ó̾¤È¥Û¥¹¥È̾¤¬¤¢¤ê¡¢
844 ¤½¤ì¤¾¤ì
845 .BR setdomainname (2),
846 .BR sethostname (2)
847 ¤Ç½¤Àµ¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
848 ¤¢¤ë UTS Ì¾Á°¶õ´Ö¤Ë¤ª¤±¤ë¼±Ê̻ҤÎÊѹ¹¤ÏƱ¤¸Ì¾Á°¶õ´Ö¤Î¾¤Î¤¹¤Ù¤Æ¤Î
849 ¥×¥í¥»¥¹¤Ë¸«¤¨¤ë¤¬¡¢Ê̤ΠUTS Ì¾Á°¶õ´Ö¤Î¥×¥í¥»¥¹¤Ë¤Ï¸«¤¨¤Ê¤¤¡£
850
851 .\"O Use of this flag requires: a kernel configured with the
852 .\"O .B CONFIG_UTS_NS
853 .\"O option and that the process be privileged
854 .\"O .RB ( CAP_SYS_ADMIN ).
855 ¤³¤Î¥Õ¥é¥°¤ò»ÈÍѤ¹¤ë¤¿¤á¤Ë¤Ï¡¢
856 ¥«¡¼¥Í¥ë¤Ç¥ª¥×¥·¥ç¥ó
857 .B CONFIG_UTS_NS
858 ¤òÍ­¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤³¤È¡¢
859 ¥×¥í¥»¥¹¤¬Æø¢
860 .RB ( CAP_SYS_ADMIN )
861 ¤ò»ý¤Ã¤Æ¤¤¤ë¤³¤È¤¬É¬ÍפǤ¢¤ë¡£
862 .TP
863 .\"O .BR CLONE_PARENT " (since Linux 2.3.12)"
864 .BR CLONE_PARENT " (Linux 2.3.12 °Ê¹ß)"
865 .\"O If
866 .\"O .B CLONE_PARENT
867 .\"O is set, then the parent of the new child (as returned by
868 .\"O .BR getppid (2))
869 .\"O will be the same as that of the calling process.
870 .B CLONE_PARENT
871 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢¿·¤·¤¤»Ò¶¡¤Î
872 .RB ( getppid (2)
873 ¤ÇÊÖ¤µ¤ì¤ë) ¿Æ¥×¥í¥»¥¹¤Ï¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î¿Æ¥×¥í¥»¥¹¤ÈƱ¤¸¤Ë¤Ê¤ë¡£
874
875 .\"O If
876 .\"O .B CLONE_PARENT
877 .\"O is not set, then (as with
878 .\"O .BR fork (2))
879 .\"O the child's parent is the calling process.
880 .B CLONE_PARENT
881 ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢
882 .RB ( fork (2)
883 ¤ÈƱÍͤË) ¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤¬¤½¤Î»Ò¶¡¤Î¿Æ¤Ë¤Ê¤ë¡£
884
885 .\"O Note that it is the parent process, as returned by
886 .\"O .BR getppid (2),
887 .\"O which is signaled when the child terminates, so that
888 .\"O if
889 .\"O .B CLONE_PARENT
890 .\"O is set, then the parent of the calling process, rather than the
891 .\"O calling process itself, will be signaled.
892 »Ò¶¡¤¬½ªÎ»¤·¤¿»þ¤Ë¥·¥°¥Ê¥ë¤¬Á÷¤é¤ì¤ë¤Î¤Ï
893 .BR getppid (2)
894 ¤¬ÊÖ¤¹¿Æ¥×¥í¥»¥¹¤Ç¤¢¤ëÅÀ¤ËÃí°Õ¤¹¤ë¤³¤È¡£¤³¤Î¤¿¤á
895 .B CLONE_PARENT
896 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Ç¤Ï¤Ê¤¯¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î
897 ¿Æ¥×¥í¥»¥¹¤Ë¥·¥°¥Ê¥ë¤¬Á÷¤é¤ì¤ë¡£
898 .TP
899 .\"O .BR CLONE_PARENT_SETTID " (since Linux 2.5.49)"
900 .BR CLONE_PARENT_SETTID " (Linux 2.5.49 °Ê¹ß)"
901 .\"O Store child thread ID at location
902 .\"O .I ptid
903 .\"O in parent and child memory.
904 .\"O (In Linux 2.5.32-2.5.48 there was a flag
905 .\"O .B CLONE_SETTID
906 .\"O that did this.)
907 ¿Æ¥×¥í¥»¥¹¤È»Ò¥×¥í¥»¥¹¤Î¥á¥â¥êÆâ¤Î
908 .I ptid
909 ¤¬»Ø¤¹Îΰè¤Ë»Ò¥×¥í¥»¥¹¤Î¥¹¥ì¥Ã¥É ID ¤ò³ÊǼ¤¹¤ë¡£
910 (Linux 2.5.32-2.5.48 ¤Ç¤Ï¡¢
911 Ʊ¤¸¤³¤È¤ò¤¹¤ë
912 .B CLONE_SETTID
913 ¤È¤¤¤¦¥Õ¥é¥°¤¬Â¸ºß¤·¤¿¡£)
914 .TP
915 .\"O .BR CLONE_PID " (obsolete)"
916 .BR CLONE_PID " (ÇÑ»ßͽÄê)"
917 .\"O If
918 .\"O .B CLONE_PID
919 .\"O is set, the child process is created with the same process ID as
920 .\"O the calling process.
921 .\"O This is good for hacking the system, but otherwise
922 .\"O of not much use.
923 .\"O Since 2.3.21 this flag can be
924 .\"O specified only by the system boot process (PID 0).
925 .\"O It disappeared in Linux 2.5.16.
926 .B CLONE_PID
927 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢»Ò¥×¥í¥»¥¹¤Ï¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ÈƱ¤¸¥×¥í¥»¥¹ ID
928 ¤ÇºîÀ®¤µ¤ì¤ë¡£¤³¤ì¤Ï¥·¥¹¥Æ¥à¤ò¥Ï¥Ã¥­¥ó¥°¤¹¤ë¤Î¤Ë¤ÏÊØÍø¤À¤¬¡¢
929 ¤½¤ì°Ê³°¤Ë¤Ï¤¢¤Þ¤ê»È¤ï¤ì¤Ê¤¤¡£ Linux 2.3.21 °Ê¹ß¤Ç¤Ï¡¢
930 ¥·¥¹¥Æ¥à¤Î¥Ö¡¼¥È¥×¥í¥»¥¹ (PID 0) ¤À¤±¤¬¤³¤Î¥Õ¥é¥°¤ò»ØÄê¤Ç¤­¤ë¡£
931 Linux 2.5.16 ¤Çºï½ü¤µ¤ì¤¿¡£
932 .TP
933 .B CLONE_PTRACE
934 .\"O If
935 .\"O .B CLONE_PTRACE
936 .\"O is specified, and the calling process is being traced,
937 .\"O then trace the child also (see
938 .\"O .BR ptrace (2)).
939 .B CLONE_PTRACE
940 ¤¬»ØÄꤵ¤ì¡¢¤«¤Ä¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤¬ÄÉÀ× (trace) ¤µ¤ì¤Æ¤¤¤¿¾ì¹ç¡¢»Ò¥×¥í¥»¥¹¤â
941 ƱÍͤËÄÉÀפµ¤ì¤ë¡£
942 .RB ( ptrace (2)
943 ¤ò»²¾È¤Î¤³¤È)
944 .TP
945 .\"O .BR CLONE_SETTLS " (since Linux 2.5.32)"
946 .BR CLONE_SETTLS " (Linux 2.5.32 °Ê¹ß)"
947 .\"O The
948 .\"O .I newtls
949 .\"O argument is the new TLS (Thread Local Storage) descriptor.
950 .\"O (See
951 .\"O .BR set_thread_area (2).)
952 .I newtls
953 °ú¤­¿ô¤Ï¡¢¿·¤·¤¤ TLS (Thread Local Storage) ¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç¤¢¤ë¡£
954 .RB ( set_thread_area (2)
955 ¤ò»²¾È¤Î¤³¤È)
956 .TP
957 .B CLONE_SIGHAND
958 .\"O If
959 .\"O .B CLONE_SIGHAND
960 .\"O is set, the calling process and the child process share the same table of
961 .\"O signal handlers.
962 .\"O If the calling process or child process calls
963 .\"O .BR sigaction (2)
964 .\"O to change the behavior associated with a signal, the behavior is
965 .\"O changed in the other process as well.
966 .\"O However, the calling process and child
967 .\"O processes still have distinct signal masks and sets of pending
968 .\"O signals.
969 .\"O So, one of them may block or unblock some signals using
970 .\"O .BR sigprocmask (2)
971 .\"O without affecting the other process.
972 .B CLONE_SIGHAND
973 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤È»Ò¥×¥í¥»¥¹¤ÏƱ¤¸¥·¥°¥Ê¥ë¡¦¥Ï¥ó
974 ¥É¥é¤Î¥Æ¡¼¥Ö¥ë¤ò¶¦Í­¤¹¤ë¡£¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Þ¤¿¤Ï»Ò¥×¥í¥»¥¹¤Î¤É¤Á¤é¤«¤¬
975 .BR sigaction (2)
976 ¤ò¸Æ¤Ó½Ð¤·¤Æ¥·¥°¥Ê¥ë¤ËÂбþ¤¹¤ëÆ°ºî¤òÊѹ¹¤·¤¿¾ì¹ç¡¢
977 ¤â¤¦°ìÊý¤Î¥×¥í¥»¥¹¤Î¥·¥°¥Ê¥ëÆ°ºî¤âÊѹ¹¤µ¤ì¤ë¡£
978 ⤷¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤È»Ò¥×¥í¥»¥¹¤Ï¡¢
979 ¥×¥í¥»¥¹Ëè¤Ë¡¢¥·¥°¥Ê¥ë¡¦¥Þ¥¹¥¯ (signal mask) ¤È½èÍýÂÔ¤Á¥·¥°¥Ê¥ë¤Î½¸¹ç
980 ¤ò»ý¤Ã¤Æ¤¤¤ë¡£¤³¤Î¤¿¤á¡¢¤¢¤ë¥×¥í¥»¥¹¤Ï¡¢
981 .BR sigprocmask (2)
982 ¤ò»ÈÍѤ·¤Æ¡¢¤â¤¦°ìÊý¤Î¥×¥í¥»¥¹¤Ë±Æ¶Á¤òÍ¿¤¨¤º¤Ë
983 ¥·¥°¥Ê¥ë¤ò¶Ø»ß (block) ¤·¤¿¤êµö²Ä (unblock) ¤·¤¿¤ê¤Ç¤­¤ë¡£
984
985 .\"O If
986 .\"O .B CLONE_SIGHAND
987 .\"O is not set, the child process inherits a copy of the signal handlers
988 .\"O of the calling process at the time
989 .\"O .BR clone ()
990 .\"O is called.
991 .\"O Calls to
992 .\"O .BR sigaction (2)
993 .\"O performed later by one of the processes have no effect on the other
994 .\"O process.
995 .B CLONE_SIGHAND
996 ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢»Ò¥×¥í¥»¥¹¤Ï
997 .BR clone ()
998 ¤¬¼Â¹Ô¤µ¤ì¤¿»þÅÀ¤Ç¤Î¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î¥·¥°¥Ê¥ë¡¦¥Ï¥ó¥É¥é¤Î
999 ¥³¥Ô¡¼¤ò·Ñ¾µ¤¹¤ë¡£¤³¤ì°Ê¹ß¤Ï¡¢°ìÊý¤Î¥×¥í¥»¥¹¤¬
1000 .BR sigaction (2)
1001 ¤ò¸Æ¤Ó½Ð¤·¤Æ¤â¡¢¤â¤¦°ìÊý¤Î¥×¥í¥»¥¹¤Ë¤Ï±Æ¶Á¤òÍ¿¤¨¤Ê¤¤¡£
1002
1003 .\"O Since Linux 2.6.0-test6,
1004 .\"O .I flags
1005 .\"O must also include
1006 .\"O .B CLONE_VM
1007 .\"O if
1008 .\"O .B CLONE_SIGHAND
1009 .\"O is specified
1010 Linux 2.6.0-test6 °Ê¹ß¤Ç¤Ï¡¢
1011 .B CLONE_SIGHAND
1012 ¤ò»ØÄꤹ¤ë¾ì¹ç¡¢
1013 .B CLONE_VM
1014 ¤â
1015 .I flags
1016 ¤Ë´Þ¤á¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
1017 .TP
1018 .\"O .BR CLONE_STOPPED " (since Linux 2.6.0-test2)"
1019 .BR CLONE_STOPPED " (Linux 2.6.0-test2 °Ê¹ß)"
1020 .\"O If
1021 .\"O .B CLONE_STOPPED
1022 .\"O is set, then the child is initially stopped (as though it was sent a
1023 .\"O .B SIGSTOP
1024 .\"O signal), and must be resumed by sending it a
1025 .\"O .B SIGCONT
1026 .\"O signal.
1027 .B CLONE_STOPPED
1028 ¤¬ÀßÄꤵ¤ì¤ë¤È¡¢»Ò¥×¥í¥»¥¹¤ÏºÇ½é
1029 .RB ( SIGSTOP
1030 ¥·¥°¥Ê¥ë¤òÁ÷¤é¤ì¤¿¤«¤Î¤è¤¦¤Ë) Ää»ß¤·¤¿¾õÂ֤Ȥʤ롣
1031 »Ò¥×¥í¥»¥¹¤òºÆ³«¤µ¤»¤ë¤Ë¤Ï
1032 .B SIGCONT
1033 ¥·¥°¥Ê¥ë¤òÁ÷¿®¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
1034
1035 .\"O .I "From Linux 2.6.25 this flag is deprecated."
1036 .\"O You probably never wanted to use it,
1037 .\"O you certainly shouldn't be using it, and soon it will go away.
1038 .I "Linux 2.6.25 °Ê¹ß¡¢¤³¤Î¥Õ¥é¥°¤ÏÈó¿ä¾©¤Ç¤¢¤ë¡£"
1039 ¤³¤Î¥Õ¥é¥°¤ò»È¤¤¤¿¤¤¤È»×¤¦¤³¤È¤Ï·è¤·¤Æ¤Ê¤¤¤À¤í¤¦¤·¡¢
1040 ³Î¼Â¤Ë»È¤ï¤Ê¤¤¤è¤¦¤Ë¤¹¤Ù¤­¤Ç¤¢¤ë¡£
1041 ¤³¤Î¥Õ¥é¥°¤Ï¶á¤¤¤¦¤Á¤Ë¤Ê¤¯¤Ê¤ë¤³¤È¤À¤í¤¦¡£
1042 .\" glibc 2.8 removed this defn from bits/sched.h
1043 .TP
1044 .\"O .BR CLONE_SYSVSEM " (since Linux 2.5.10)"
1045 .BR CLONE_SYSVSEM " (Linux 2.5.10 °Ê¹ß)"
1046 .\"O If
1047 .\"O .B CLONE_SYSVSEM
1048 .\"O is set, then the child and the calling process share
1049 .\"O a single list of System V semaphore undo values (see
1050 .\"O .BR semop (2)).
1051 .\"O If this flag is not set, then the child has a separate undo list,
1052 .\"O which is initially empty.
1053 .B CLONE_SYSVSEM
1054 ¤¬¥»¥Ã¥È¤µ¤ì¤ë¤È¡¢»Ò¥×¥í¥»¥¹¤È¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Ï°ì¤Ä¤Î
1055 System V ¥»¥Þ¥Õ¥©¤Î¥¢¥ó¥É¥¥Ãͥꥹ¥È
1056 .RB ( semop (2)
1057 »²¾È) ¤ò¶¦Í­¤¹¤ë¡£¤³¤Î¥Õ¥é¥°¤¬¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢
1058 »Ò¥×¥í¥»¥¹¤ÏÆȼ«¤Î¥¢¥ó¥É¥¥¥ê¥¹¥È¤ò»ý¤Ä (¥ê¥¹¥È¤Î½é´üÃͤ϶õ¤Ç¤¢¤ë)¡£
1059 .TP
1060 .\"O .BR CLONE_THREAD " (since Linux 2.4.0-test8)"
1061 .BR CLONE_THREAD " (Linux 2.4.0-test8°Ê¹ß)"
1062 .\"O If
1063 .\"O .B CLONE_THREAD
1064 .\"O is set, the child is placed in the same thread group as the calling process.
1065 .\"O To make the remainder of the discussion of
1066 .\"O .B CLONE_THREAD
1067 .\"O more readable, the term "thread" is used to refer to the
1068 .\"O processes within a thread group.
1069 .B CLONE_THREAD
1070 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢»Ò¥×¥í¥»¥¹¤Ï¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ÈƱ¤¸¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Ë
1071 ÃÖ¤«¤ì¤ë¡£
1072 .B CLONE_THREAD
1073 ¤Ë¤Ä¤¤¤Æ¤Î°Ê¹ß¤ÎµÄÏÀ¤òÆɤߤ䤹¤¯¤¹¤ë¤¿¤á¡¢
1074 ¡Ö¥¹¥ì¥Ã¥É¡×¤È¤¤¤¦ÍѸì¤Ï¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤ÎÃæ¤Î¥×¥í¥»¥¹¤ò
1075 »²¾È¤¹¤ë¤Î¤Ë»È¤¦¤³¤È¤È¤¹¤ë¡£
1076
1077 .\"O Thread groups were a feature added in Linux 2.4 to support the
1078 .\"O POSIX threads notion of a set of threads that share a single PID.
1079 .\"O Internally, this shared PID is the so-called
1080 .\"O thread group identifier (TGID) for the thread group.
1081 .\"O Since Linux 2.4, calls to
1082 .\"O .BR getpid (2)
1083 .\"O return the TGID of the caller.
1084 ¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Ï¡¢ ¥¹¥ì¥Ã¥É½¸¹ç¤Ç°ì¤Ä¤Î PID ¤ò¶¦Í­¤¹¤ë¤È¤¤¤¦ POSIX
1085 ¥¹¥ì¥Ã¥É¤Î³µÇ°¤ò¥µ¥Ý¡¼¥È¤¹¤ë¤¿¤á¤Ë Linux 2.4 ¤Ë²Ã¤¨¤é¤ì¤¿µ¡Ç½¤Ç¤¢¤Ã¤¿¡£
1086 ÆâÉôŪ¤Ë¤Ï¡¢¤³¤Î¶¦Í­ PID ¤Ï¤¤¤ï¤æ¤ë¤½¤Î¥¹¥ì¥Ã¥É¥°¥ë¡¼¥×¤Î
1087 ¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¼±Ê̻Ҡ(TGID) ¤Ç¤¢¤ë¡£
1088 Linux 2.4 °Ê¹ß¤Ç¤Ï¡¢
1089 .BR getpid (2)
1090 ¤Î¸Æ¤Ó½Ð¤·¤Ç¤Ï¤½¤Î¥×¥í¥»¥¹¤Î¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥× ID ¤òÊÖ¤¹¡£
1091
1092 .\"O The threads within a group can be distinguished by their (system-wide)
1093 .\"O unique thread IDs (TID).
1094 .\"O A new thread's TID is available as the function result
1095 .\"O returned to the caller of
1096 .\"O .BR clone (),
1097 .\"O and a thread can obtain
1098 .\"O its own TID using
1099 .\"O .BR gettid (2).
1100 ¤¢¤ë¥°¥ë¡¼¥×¤Ë°¤¹¤ë¥¹¥ì¥Ã¥É¤Ï (¥·¥¹¥Æ¥àÁ´ÂΤÇ) °ì°Õ¤Ê¥¹¥ì¥Ã¥É ID (TID)
1101 ¤Ç¶èÊ̤Ǥ­¤ë¡£¿·¤·¤¤¥¹¥ì¥Ã¥É¤Î TID ¤Ï
1102 .BR clone ()
1103 ¤Î¸Æ¤Ó½Ð¤·¸µ¤Ø´Ø¿ô¤Î·ë²Ì¤È¤·¤ÆÊÖ¤µ¤ì¡¢
1104 ¥¹¥ì¥Ã¥É¤Ï¼«Ê¬¼«¿È¤Î TID ¤ò
1105 .BR gettid (2)
1106 ¤Ç¼èÆÀ¤Ç¤­¤ë¡£
1107
1108 .\"O When a call is made to
1109 .\"O .BR clone ()
1110 .\"O without specifying
1111 .\"O .BR CLONE_THREAD ,
1112 .\"O then the resulting thread is placed in a new thread group
1113 .\"O whose TGID is the same as the thread's TID.
1114 .\"O This thread is the
1115 .\"O .I leader
1116 .\"O of the new thread group.
1117 .B CLONE_THREAD
1118 ¤ò»ØÄꤻ¤º¤Ë
1119 .BR clone ()
1120 ¤Î¸Æ¤Ó½Ð¤·¤¬¹Ô¤ï¤ì¤ë¤È¡¢
1121 À¸À®¤µ¤ì¤¿¥¹¥ì¥Ã¥É¤Ï¤½¤Î¥¹¥ì¥Ã¥É¤Î TID ¤ÈƱ¤¸ÃͤΠTGID ¤ò»ý¤Ä
1122 ¿·¤·¤¤¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤ËÃÖ¤«¤ì¤ë¡£¤³¤Î¥¹¥ì¥Ã¥É¤Ï
1123 ¿·¤·¤¤¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Î¡Ö¥ê¡¼¥À¡¼¡×¤Ç¤¢¤ë¡£
1124
1125 .\"O A new thread created with
1126 .\"O .B CLONE_THREAD
1127 .\"O has the same parent process as the caller of
1128 .\"O .BR clone ()
1129 .\"O (i.e., like
1130 .\"O .BR CLONE_PARENT ),
1131 .\"O so that calls to
1132 .\"O .BR getppid (2)
1133 .\"O return the same value for all of the threads in a thread group.
1134 .B CLONE_THREAD
1135 ¤ò»ØÄꤷ¤ÆºîÀ®¤µ¤ì¤¿¿·¤·¤¤¥¹¥ì¥Ã¥É¤Ï¡¢
1136 .RB ( CLONE_PARENT
1137 ¤Î¾ì¹ç¤ÈƱÍͤË)
1138 .BR clone ()
1139 ¤ò¸Æ¤Ó½Ð¤·¸µ¤ÈƱ¤¸¿Æ¥×¥í¥»¥¹¤ò»ý¤Ä¡£
1140 ¤½¤Î¤¿¤á¡¢
1141 .BR getppid (2)
1142 ¤ò¸Æ¤Ö¤È¡¢°ì¤Ä¤Î¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Ë°¤¹¥¹¥ì¥Ã¥É¤ÏÁ´¤ÆƱ¤¸ÃͤòÊÖ¤¹¡£
1143 .\"O When a
1144 .\"O .B CLONE_THREAD
1145 .\"O thread terminates, the thread that created it using
1146 .\"O .BR clone ()
1147 .\"O is not sent a
1148 .\"O .B SIGCHLD
1149 .\"O (or other termination) signal;
1150 .\"O nor can the status of such a thread be obtained
1151 .\"O using
1152 .\"O .BR wait (2).
1153 .\"O (The thread is said to be
1154 .\"O .IR detached .)
1155 .B CLONE_THREAD
1156 ¤Çºî¤é¤ì¤¿¥¹¥ì¥Ã¥É¤¬½ªÎ»¤·¤¿ºÝ¤Ë¡¢
1157 ¤½¤Î¥¹¥ì¥Ã¥É¤ò
1158 .BR clone (2)
1159 ¤ò»È¤Ã¤ÆÀ¸À®¤·¤¿¥¹¥ì¥Ã¥É¤Ë¤Ï
1160 .B SIGCHLD
1161 (¤â¤·¤¯¤Ï¾¤Î½ªÎ»¥·¥°¥Ê¥ë) ¤ÏÁ÷¿®¤µ¤ì¤Ê¤¤¡£
1162 ¤Þ¤¿¡¢
1163 .BR wait (2)
1164 ¤ò»È¤Ã¤Æ½ªÎ»¤·¤¿¥¹¥ì¥Ã¥É¤Î¾õÂÖ¤ò¼èÆÀ¤¹¤ë¤³¤È¤â¤Ç¤­¤Ê¤¤
1165 (¤½¤Î¤è¤¦¤Ê¥¹¥ì¥Ã¥É¤Ï
1166 .I detached
1167 (ʬΥ¤µ¤ì¤¿) ¤È¤¤¤ï¤ì¤ë)¡£
1168
1169 .\"O After all of the threads in a thread group terminate
1170 .\"O the parent process of the thread group is sent a
1171 .\"O .B SIGCHLD
1172 .\"O (or other termination) signal.
1173 ¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Ë°¤¹Á´¤Æ¤Î¥¹¥ì¥Ã¥É¤¬½ªÎ»¤·¤¿¸å¡¢
1174 ¤½¤Î¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Î¿Æ¥×¥í¥»¥¹¤Ë
1175 .B SIGCHLD
1176 (¤â¤·¤¯¤Ï¾¤Î½ªÎ»¥·¥°¥Ê¥ë) ¤¬Á÷¤é¤ì¤ë¡£
1177
1178 .\"O If any of the threads in a thread group performs an
1179 .\"O .BR execve (2),
1180 .\"O then all threads other than the thread group leader are terminated,
1181 .\"O and the new program is executed in the thread group leader.
1182 ¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Ë°¤¹¤¤¤º¤ì¤«¤Î¥¹¥ì¥Ã¥É¤¬
1183 .BR execve (2)
1184 ¤ò¼Â¹Ô¤¹¤ë¤È¡¢¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¡¦¥ê¡¼¥À¡¼°Ê³°¤ÎÁ´¤Æ¤Î¥¹¥ì¥Ã¥É¤Ï
1185 ½ªÎ»¤µ¤ì¡¢¿·¤·¤¤¥×¥í¥»¥¹¤¬¤½¤Î¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¡¦¥ê¡¼¥À¡¼¤Î²¼¤Ç
1186 ¼Â¹Ô¤µ¤ì¤ë¡£
1187
1188 .\"O If one of the threads in a thread group creates a child using
1189 .\"O .BR fork (2),
1190 .\"O then any thread in the group can
1191 .\"O .BR wait (2)
1192 .\"O for that child.
1193 ¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Ë°¤¹¥¹¥ì¥Ã¥É¤Î°ì¤Ä¤¬
1194 .BR fork (2)
1195 ¤ò»È¤Ã¤Æ»Ò¥×¥í¥»¥¹¤òºîÀ®¤·¤¿¾ì¹ç¡¢
1196 ¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Î¤É¤Î¥¹¥ì¥Ã¥É¤Ç¤¢¤Ã¤Æ¤â
1197 ¤½¤Î»Ò¶¡¤ò
1198 .BR wait (2)
1199 ¤Ç¤­¤ë¡£
1200
1201 .\"O Since Linux 2.5.35,
1202 .\"O .I flags
1203 .\"O must also include
1204 .\"O .B CLONE_SIGHAND
1205 .\"O if
1206 .\"O .B CLONE_THREAD
1207 .\"O is specified.
1208 Linux 2.5.35 °Ê¹ß¤Ç¤Ï¡¢
1209 .B CLONE_THREAD
1210 ¤ò»ØÄꤹ¤ë¾ì¹ç¡¢
1211 .I flags
1212 ¤Ë
1213 .B CLONE_SIGHAND
1214 ¤â´Þ¤Þ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
1215
1216 .\"O Signals may be sent to a thread group as a whole (i.e., a TGID) using
1217 .\"O .BR kill (2),
1218 .\"O or to a specific thread (i.e., TID) using
1219 .\"O .BR tgkill (2).
1220 .BR kill (2)
1221 ¤ò»È¤Ã¤Æ¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×Á´ÂΠ(¤Ä¤Þ¤ê TGID) ¤Ë¥·¥°¥Ê¥ë¤òÁ÷¤ë¤³¤È¤â¤Ç¤­¤ì¤Ð¡¢
1222 .BR tgkill (2)
1223 ¤ò»È¤Ã¤ÆÆÃÄê¤Î¥¹¥ì¥Ã¥É (¤Ä¤Þ¤ê TID) ¤Ë¥·¥°¥Ê¥ë¤òÁ÷¤ë¤³¤È¤â¤Ç¤­¤ë¡£
1224
1225 .\"O Signal dispositions and actions are process-wide:
1226 .\"O if an unhandled signal is delivered to a thread, then
1227 .\"O it will affect (terminate, stop, continue, be ignored in)
1228 .\"O all members of the thread group.
1229 ¥·¥°¥Ê¥ë¤ÎÇÛÁ÷¤È½èÍý¤Ï¥×¥í¥»¥¹Á´ÂΤ˱ƶÁ¤¹¤ë:
1230 ¥Ï¥ó¥É¥é¤òÀßÄꤷ¤Æ¤¤¤Ê¤¤¥·¥°¥Ê¥ë¤¬¤¢¤ë¥¹¥ì¥Ã¥É¤ËÇÛÁ÷¤µ¤ì¤ë¤È¡¢
1231 ¤½¤Î¥·¥°¥Ê¥ë¤Ï¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤ÎÁ´¥á¥ó¥Ð¡¼¤Ë±Æ¶Á¤òµÚ¤Ü¤¹
1232 (½ªÎ»¤·¤¿¤ê¡¢Ää»ß¤·¤¿¤ê¡¢Æ°ºî¤ò·Ñ³¤·¤¿¤ê¡¢Ìµ»ë¤µ¤ì¤¿¤ê¤¹¤ë)¡£
1233
1234 .\"O Each thread has its own signal mask, as set by
1235 .\"O .BR sigprocmask (2),
1236 .\"O but signals can be pending either: for the whole process
1237 .\"O (i.e., deliverable to any member of the thread group),
1238 .\"O when sent with
1239 .\"O .BR kill (2);
1240 .\"O or for an individual thread, when sent with
1241 .\"O .BR tgkill (2).
1242 .\"O A call to
1243 .\"O .BR sigpending (2)
1244 .\"O returns a signal set that is the union of the signals pending for the
1245 .\"O whole process and the signals that are pending for the calling thread.
1246 ³Æ¡¹¤Î¥¹¥ì¥Ã¥É¤ÏÆȼ«¤Î¥·¥°¥Ê¥ë¥Þ¥¹¥¯¤ò»ý¤Ã¤Æ¤ª¤ê¡¢
1247 .BR sigprocmask (2)
1248 ¤ÇÀßÄê¤Ç¤­¤ë¡£
1249 ¤À¤¬¡¢½èÍýÂÔ¤Á¤Î¥·¥°¥Ê¥ë¤Ë¤Ï¡¢
1250 .BR kill (2)
1251 ¤ÇÁ÷¿®¤µ¤ì¤ë¥×¥í¥»¥¹Á´ÂΤËÂФ¹¤ë¤â¤Î (¤Ä¤Þ¤ê¡¢¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Î
1252 ¤É¤Î¥á¥ó¥Ð¡¼¤Ë¤âÇÛÁ÷¤Ç¤­¤ë¤â¤Î) ¤È¡¢
1253 .BR tgkill (2)
1254 ¤ÇÁ÷¿®¤µ¤ì¤ë¸Ä¡¹¤Î¥¹¥ì¥Ã¥É¤ËÂФ¹¤ë¤â¤Î¤¬¤¢¤ê¤¨¤ë¡£
1255 .BR sigpending (2)
1256 ¤ò¸Æ¤Ó½Ð¤¹¤È¡¢¥×¥í¥»¥¹Á´ÂΤËÂФ¹¤ë½èÍýÂÔ¤Á¥·¥°¥Ê¥ë¤È¸Æ¤Ó½Ð¤·¸µ¤Î
1257 ¥¹¥ì¥Ã¥É¤ËÂФ¹¤ë½èÍýÂÔ¤Á¥·¥°¥Ê¥ë¤ò·ë¹ç¤·¤¿¥·¥°¥Ê¥ë½¸¹ç¤¬ÊÖ¤µ¤ì¤ë¡£
1258
1259 .\"O If
1260 .\"O .BR kill (2)
1261 .\"O is used to send a signal to a thread group,
1262 .\"O and the thread group has installed a handler for the signal, then
1263 .\"O the handler will be invoked in exactly one, arbitrarily selected
1264 .\"O member of the thread group that has not blocked the signal.
1265 .\"O If multiple threads in a group are waiting to accept the same signal using
1266 .\"O .BR sigwaitinfo (2),
1267 .\"O the kernel will arbitrarily select one of these threads
1268 .\"O to receive a signal sent using
1269 .\"O .BR kill (2).
1270 .BR kill (2)
1271 ¤ò»È¤Ã¤Æ¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Ë¥·¥°¥Ê¥ë¤¬Á÷¤é¤ì¤¿¾ì¹ç¤Ç¡¢
1272 ¤½¤Î¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤¬¤½¤Î¥·¥°¥Ê¥ë¤ËÂФ¹¤ë¥·¥°¥Ê¥ë¡¦¥Ï¥ó¥É¥é¤¬
1273 ÅÐÏ¿¤µ¤ì¤Æ¤¤¤¿¤È¤­¤Ë¤Ï¡¢¥·¥°¥Ê¥ë¡¦¥Ï¥ó¥É¥é¤Ï¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Î
1274 ¥á¥ó¥Ð¡¼¤Î¤¦¤Á¡¢¤¿¤À°ì¤Ä¤Î¥¹¥ì¥Ã¥É¤Ç¤À¤±µ¯Æ°¤µ¤ì¤ë¡£¥Ï¥ó¥É¥é¤¬
1275 µ¯Æ°¤µ¤ì¤ë¥¹¥ì¥Ã¥É¤Ï¡¢¤½¤Î¥·¥°¥Ê¥ë¤ò¶Ø»ß (block) ¤·¤Æ¤¤¤Ê¤¤
1276 ¥á¥ó¥Ð¡¼¤ÎÃ椫¤é°ì¤Ä¤À¤±¤¬¾¡¼ê¤Ë (arbitrarily) Áª¤Ð¤ì¤ë¡£
1277 ¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Ë°¤¹Ê£¿ô¤Î¥¹¥ì¥Ã¥É¤¬
1278 .BR sigwaitinfo (2)
1279 ¤ò»È¤Ã¤ÆƱ¤¸¥·¥°¥Ê¥ë¤òÂԤäƤ¤¤ë¾ì¹ç¡¢
1280 ¤³¤ì¤é¤Î¥¹¥ì¥Ã¥É¤ÎÃ椫¤é°ì¤Ä¤ò¥«¡¼¥Í¥ë¤¬¾¡¼ê¤ËÁªÂò¤·¡¢
1281 ¤½¤Î¥¹¥ì¥Ã¥É¤¬
1282 .B kill (2)
1283 ¤ò»È¤Ã¤ÆÁ÷¿®¤µ¤ì¤¿¥·¥°¥Ê¥ë¤ò¼õ¿®¤¹¤ë¡£
1284 .TP
1285 .\"O .BR CLONE_UNTRACED " (since Linux 2.5.46)"
1286 .BR CLONE_UNTRACED " (Linux 2.5.46 °Ê¹ß)"
1287 .\"O If
1288 .\"O .B CLONE_UNTRACED
1289 .\"O is specified, then a tracing process cannot force
1290 .\"O .B CLONE_PTRACE
1291 .\"O on this child process.
1292 .B CLONE_UNTRACED
1293 ¤¬»ØÄꤵ¤ì¤ë¤È¡¢ trace ¤ò¹Ô¤Ã¤Æ¤¤¤ë¥×¥í¥»¥¹¤Ï
1294 ¤³¤Î»Ò¥×¥í¥»¥¹¤Ë
1295 .B CLONE_PTRACE
1296 ¤òŬÍѤ¹¤ë¤³¤È¤¬¤Ç¤­¤Ê¤¤¡£
1297 .TP
1298 .B CLONE_VFORK
1299 .\"O If
1300 .\"O .B CLONE_VFORK
1301 .\"O is set, the execution of the calling process is suspended
1302 .\"O until the child releases its virtual memory
1303 .\"O resources via a call to
1304 .\"O .BR execve (2)
1305 .\"O or
1306 .\"O .BR _exit (2)
1307 .\"O (as with
1308 .\"O .BR vfork (2)).
1309 .B CLONE_VFORK
1310 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢
1311 .RB ( vfork (2)
1312 ¤ÈƱÍͤË) »Ò¥×¥í¥»¥¹¤¬
1313 .BR execve (2)
1314 ¤Þ¤¿¤Ï
1315 .BR _exit (2)
1316 ¤Ë¤è¤Ã¤Æ²¾ÁÛ¥á¥â¥ê¤ò²òÊü¤¹¤ë¤Þ¤Ç¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î¼Â¹Ô¤ÏÄä»ß¤µ¤ì¤ë¡£
1317
1318 .\"O If
1319 .\"O .B CLONE_VFORK
1320 .\"O is not set then both the calling process and the child are schedulable
1321 .\"O after the call, and an application should not rely on execution occurring
1322 .\"O in any particular order.
1323 .B CLONE_VFORK
1324 ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢
1325 .BR clone ()
1326 ¸Æ¤Ó½Ð¤·¸å¤Ï¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤È»Ò¥×¥í¥»¥¹¤Î
1327 ξÊý¤¬¥¹¥±¥¸¥å¡¼¥ëÂоݤȤʤꡢ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï¤³¤ì¤é¤Î¥×¥í¥»¥¹¤Î
1328 ¼Â¹Ô½ç½ø¤Ë°Í¸¤·¤Ê¤¤¤è¤¦¤Ë¤¹¤Ù¤­¤Ç¤¢¤ë¡£
1329 .TP
1330 .B CLONE_VM
1331 .\"O If
1332 .\"O .B CLONE_VM
1333 .\"O is set, the calling process and the child process run in the same memory
1334 .\"O space.
1335 .\"O In particular, memory writes performed by the calling process
1336 .\"O or by the child process are also visible in the other process.
1337 .\"O Moreover, any memory mapping or unmapping performed with
1338 .\"O .BR mmap (2)
1339 .\"O or
1340 .\"O .BR munmap (2)
1341 .\"O by the child or calling process also affects the other process.
1342 .B CLONE_VM
1343 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤È»Ò¥×¥í¥»¥¹¤ÏƱ¤¸¥á¥â¥ê¶õ´Ö¤Ç
1344 ¼Â¹Ô¤µ¤ì¤ë¡£Æäˡ¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ä»Ò¥×¥í¥»¥¹¤Î°ìÊý¤¬¥á¥â¥ê¤Ë
1345 ½ñ¤­¹þ¤ó¤ÀÆâÍƤϤ⤦°ìÊý¤Î¥×¥í¥»¥¹¤«¤é¤â¸«¤ë¤³¤È¤¬¤Ç¤­¤ë¡£¤µ¤é¤Ë¡¢
1346 »Ò¥×¥í¥»¥¹¤ä¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î°ìÊý¤¬
1347 .BR mmap (2)
1348 ¤ä
1349 .BR munmap (2)
1350 ¤ò»È¤Ã¤Æ¥á¥â¥ê¤ò¥Þ¥Ã¥×¤·¤¿¤ê¥¢¥ó¥Þ¥Ã¥×¤·¤¿¾ì¹ç¡¢
1351 ¤â¤¦°ìÊý¤Î¥×¥í¥»¥¹¤Ë¤â±Æ¶Á¤¬µÚ¤Ö¡£
1352
1353 .\"O If
1354 .\"O .B CLONE_VM
1355 .\"O is not set, the child process runs in a separate copy of the memory
1356 .\"O space of the calling process at the time of
1357 .\"O .BR clone ().
1358 .\"O Memory writes or file mappings/unmappings performed by one of the
1359 .\"O processes do not affect the other, as with
1360 .\"O .BR fork (2).
1361 .B CLONE_VM
1362 ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢»Ò¥×¥í¥»¥¹¤Ï
1363 .BR clone ()
1364 ¤¬¼Â¹Ô¤µ¤ì¤¿»þÅÀ¤Ç¤Î¡¢¿Æ¥×¥í¥»¥¹¤Î¥á¥â¥ê¶õ´Ö¤ò¥³¥Ô¡¼¤·¤¿
1365 Ê̤Υá¥â¥ê¶õ´Ö¤Ç¼Â¹Ô¤µ¤ì¤ë¡£
1366 °ìÊý¤Î¥×¥í¥»¥¹¤¬¹Ô¤Ã¤¿¥á¥â¥ê¤Ø¤Î½ñ¤­¹þ¤ß¤ä
1367 ¥Õ¥¡¥¤¥ë¤Î¥Þ¥Ã¥×/¥¢¥ó¥Þ¥Ã¥×¤Ï¡¢
1368 .BR fork (2)
1369 ¤Î¾ì¹ç¤ÈƱÍÍ¡¢¤â¤¦°ìÊý¤Î¥×¥í¥»¥¹¤Ë¤Ï±Æ¶Á¤·¤Ê¤¤¡£
1370 .SS "sys_clone"
1371 .\"O The
1372 .\"O .B sys_clone
1373 .\"O system call corresponds more closely to
1374 .\"O .BR fork (2)
1375 .\"O in that execution in the child continues from the point of the
1376 .\"O call.
1377 .\"O Thus,
1378 .\"O .B sys_clone
1379 .\"O only requires the
1380 .\"O .I flags
1381 .\"O and
1382 .\"O .I child_stack
1383 .\"O arguments, which have the same meaning as for
1384 .\"O .BR clone ().
1385 .\"O (Note that the order of these arguments differs from
1386 .\"O .BR clone ().)
1387 .B sys_clone
1388 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï¡¢¤è¤ê
1389 .BR fork (2)
1390 ¤Ë¶á¤¤¤«¤¿¤Á¤Ë¤Ê¤Ã¤Æ¤ª¤ê¡¢»Ò¥×¥í¥»¥¹¤Î¼Â¹Ô¤¬¸Æ¤Ó½Ð¤·¤¬¹Ô¤ï¤ì¤¿¾ì½ê¤«¤é
1391 ³¤±¤é¤ì¤ë¡£
1392 ¤½¤Î¤¿¤á¡¢
1393 .B sys_clone
1394 ¤¬É¬ÍפȤ¹¤ë°ú¤­¿ô¤Ï
1395 .I flags
1396 ¤È
1397 .I child_stack
1398 ¤À¤±¤Ç¤¢¤ê¡¢¤½¤ì¤é¤Ï
1399 .BR clone ()
1400 ¤ÈƱ¤¸°ÕÌ£¤ò»ý¤Ä
1401 (¤³¤ì¤é¤Î°ú¤­¿ô¤Î½çÈÖ¤Ï
1402 .BR clone ()
1403 ¤È¤Ï°Û¤Ê¤ë¤³¤È¤ËÃí°Õ¤»¤è)¡£
1404
1405 .\"O Another difference for
1406 .\"O .B sys_clone
1407 .\"O is that the
1408 .\"O .I child_stack
1409 .\"O argument may be zero, in which case copy-on-write semantics ensure that the
1410 .\"O child gets separate copies of stack pages when either process modifies
1411 .\"O the stack.
1412 .\"O In this case, for correct operation, the
1413 .\"O .B CLONE_VM
1414 .\"O option should not be specified.
1415 .B sys_clone
1416 ¤Î¤â¤¦°ì¤Ä¤Î°ã¤¤¤Ï¡¢
1417 .I child_stack
1418 °ú¤­¿ô¤¬¥¼¥í¤Ç¤âÎɤ¤¤³¤È¤Ç¤¢¤ë¡£¤³¤Î¾ì¹ç¤Ë¤Ï¡¢¤É¤Á¤é¤«¤Î¥×¥í¥»¥¹¤¬
1419 ¥¹¥¿¥Ã¥¯¤òÊѹ¹¤·¤¿»þ¤Ë¡¢½ñ¤­¹þ¤ß»þ¥³¥Ô¡¼ (copy-on-write) Êý¼°¤Ë¤è¤ê
1420 »Ò¥×¥í¥»¥¹¤¬¥¹¥¿¥Ã¥¯¡¦¥Ú¡¼¥¸¤ÎÆÈΩ¤·¤¿¥³¥Ô¡¼¤òÆÀ¤é¤ì¤ë¤³¤È¤¬Êݾڤµ¤ì¤ë¡£
1421 ¤³¤Î¾ì¹ç¡¢Àµ¾ï¤ËÆ°ºî¤µ¤»¤ë¤¿¤á¤Ë¤Ï¡¢
1422 .B CLONE_VM
1423 ¥ª¥×¥·¥ç¥ó¤ò»ØÄꤷ¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
1424
1425 .\"O In Linux 2.4 and earlier,
1426 .\"O .BR clone ()
1427 .\"O does not take arguments
1428 .\"O .IR ptid ,
1429 .\"O .IR tls ,
1430 .\"O and
1431 .\"O .IR ctid .
1432 Linux 2.4 °ÊÁ°¤Ç¤Ï¡¢
1433 .BR clone ()
1434 ¤Ï°ú¤­¿ô
1435 .IR ptid ,
1436 .IR tls ,
1437 .IR ctid
1438 ¤ò¼è¤é¤Ê¤¤¡£
1439 .\"O .SH "RETURN VALUE"
1440 .SH ÊÖ¤êÃÍ
1441 .\"O .\" gettid(2) returns current->pid;
1442 .\"O .\" getpid(2) returns current->tgid;
1443 .\"O On success, the thread ID of the child process is returned
1444 .\"O in the caller's thread of execution.
1445 .\"O On failure, \-1 is returned
1446 .\"O in the caller's context, no child process will be created, and
1447 .\"O .I errno
1448 .\"O will be set appropriately.
1449 .\" gettid(2) ¤Ï current->pid ¤òÊÖ¤¹
1450 .\" getpid(2) ¤Ï current->tgid ¤òÊÖ¤¹
1451 À®¸ù¤·¤¿¾ì¹ç¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¼Â¹Ô¥¹¥ì¥Ã¥É¤Ë¤Ï»Ò¥×¥í¥»¥¹¤Î¥¹¥ì¥Ã¥ÉID ¤¬ÊÖ¤µ¤ì¤ë¡£
1452 ¼ºÇÔ¤·¤¿¾ì¹ç¡¢ ¸Æ¤Ó½Ð¤·¸µ¤Î¥³¥ó¥Æ¥­¥¹¥È¤Ë¤Ï \-1 ¤¬ÊÖ¤µ¤ì¡¢»Ò¥×¥í¥»¥¹¤Ï
1453 ºîÀ®¤µ¤ì¤º¡¢
1454 .I errno
1455 ¤¬Å¬ÀÚ¤ËÀßÄꤵ¤ì¤ë¡£
1456 .\"O .SH ERRORS
1457 .SH ¥¨¥é¡¼
1458 .TP
1459 .B EAGAIN
1460 .\"O Too many processes are already running.
1461 ¤¹¤Ç¤Ë¼Â¹ÔÃæ¤Î¥×¥í¥»¥¹¤¬Â¿¤¹¤®¤ë¡£
1462 .TP
1463 .B EINVAL
1464 .\"O .B CLONE_SIGHAND
1465 .\"O was specified, but
1466 .\"O .B CLONE_VM
1467 .\"O was not.
1468 .\"O (Since Linux 2.6.0-test6.)
1469 .B CLONE_SIGHAND
1470 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤¿¤¬¡¢
1471 .B CLONE_VM
1472 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤«¤Ã¤¿¡£
1473 (Linux 2.6.0-test6 °Ê¹ß)
1474 .TP
1475 .B EINVAL
1476 .\"O .B CLONE_THREAD
1477 .\"O was specified, but
1478 .\"O .B CLONE_SIGHAND
1479 .\"O was not.
1480 .\"O (Since Linux 2.5.35.)
1481 .B CLONE_THREAD
1482 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤¿¤¬¡¢
1483 .B CLONE_SIGHAND
1484 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤«¤Ã¤¿¡£
1485 (Linux 2.5.35 °Ê¹ß)
1486 .\" .TP
1487 .\" .B EINVAL
1488 .\"O .\" Precisely one of
1489 .\"O .\" .B CLONE_DETACHED
1490 .\"O .\" and
1491 .\"O .\" .B CLONE_THREAD
1492 .\"O .\" was specified.
1493 .\"O .\" (Since Linux 2.6.0-test6.)
1494 .\" .B CLONE_DETACHED
1495 .\" ¤È
1496 .\" .B CLONE_THREAD
1497 .\" ¤Î¤¤¤º¤ì¤«°ìÊý¤À¤±¤¬»ØÄꤵ¤ì¤¿¡£
1498 .\" (Linux 2.6.0-test6 °Ê¹ß)
1499 .TP
1500 .B EINVAL
1501 .\"O Both
1502 .\"O .B CLONE_FS
1503 .\"O and
1504 .\"O .B CLONE_NEWNS
1505 .\"O were specified in
1506 .\"O .IR flags .
1507 .B CLONE_FS
1508 ¤È
1509 .B CLONE_NEWNS
1510 ¤ÎξÊý¤¬
1511 .I flags
1512 ¤Ë»ØÄꤵ¤ì¤¿¡£
1513 .TP
1514 .B EINVAL
1515 .\"O Both
1516 .\"O .B CLONE_NEWIPC
1517 .\"O and
1518 .\"O .B CLONE_SYSVSEM
1519 .\"O were specified in
1520 .\"O .IR flags .
1521 .B CLONE_NEWIPC
1522 ¤È
1523 .B CLONE_SYSVSEM
1524 ¤ÎξÊý¤¬
1525 .I flags
1526 ¤Ë»ØÄꤵ¤ì¤¿¡£
1527 .TP
1528 .B EINVAL
1529 .\"O Both
1530 .\"O .BR CLONE_NEWPID
1531 .\"O and
1532 .\"O .BR CLONE_THREAD
1533 .\"O were specified in
1534 .\"O .IR flags .
1535 .B CLONE_NEWPID
1536 ¤È
1537 .B CLONE_THREAD
1538 ¤ÎξÊý¤¬
1539 .I flags
1540 ¤Ë»ØÄꤵ¤ì¤¿¡£
1541 .TP
1542 .B EINVAL
1543 .\"O Returned by
1544 .\"O .BR clone ()
1545 .\"O when a zero value is specified for
1546 .\"O .IR child_stack .
1547 .I child_stack
1548 ¤Ë¥¼¥í¤ò»ØÄꤷ¤¿¾ì¹ç¤Ë
1549 .BR clone ()
1550 ¤¬ÊÖ¤¹¡£
1551 .TP
1552 .B EINVAL
1553 .\"O .BR CLONE_NEWIPC
1554 .\"O was specified in
1555 .\"O .IR flags ,
1556 .\"O but the kernel was not configured with the
1557 .\"O .B CONFIG_SYSVIPC
1558 .\"O and
1559 .\"O .BR CONFIG_IPC_NS
1560 .\"O options.
1561 .I flags
1562 ¤Ë
1563 .B CLONE_NEWIPC
1564 ¤¬»ØÄꤵ¤ì¤¿¤¬¡¢¥«¡¼¥Í¥ë¤Ç¥ª¥×¥·¥ç¥ó
1565 .B CONFIG_SYSVIPC
1566 ¤È
1567 .B CONFIG_IPC_NS
1568 ¤¬Í­¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤Ê¤«¤Ã¤¿¡£
1569 .TP
1570 .B EINVAL
1571 .\"O .BR CLONE_NEWNET
1572 .\"O was specified in
1573 .\"O .IR flags ,
1574 .\"O but the kernel was not configured with the
1575 .\"O .B CONFIG_NET_NS
1576 .\"O option.
1577 .I flags
1578 ¤Ë
1579 .B CLONE_NEWNET
1580 ¤¬»ØÄꤵ¤ì¤¿¤¬¡¢¥«¡¼¥Í¥ë¤Ç¥ª¥×¥·¥ç¥ó
1581 .B CONFIG_NET_NS
1582 ¤¬Í­¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤Ê¤«¤Ã¤¿¡£
1583 .TP
1584 .B EINVAL
1585 .\"O .BR CLONE_NEWPID
1586 .\"O was specified in
1587 .\"O .IR flags ,
1588 .\"O but the kernel was not configured with the
1589 .\"O .B CONFIG_PID_NS
1590 .\"O option.
1591 .I flags
1592 ¤Ë
1593 .B CLONE_NEWPID
1594 ¤¬»ØÄꤵ¤ì¤¿¤¬¡¢¥«¡¼¥Í¥ë¤Ç¥ª¥×¥·¥ç¥ó
1595 .B CONFIG_PID_NS
1596 ¤¬Í­¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤Ê¤«¤Ã¤¿¡£
1597 .TP
1598 .B EINVAL
1599 .\"O .BR CLONE_NEWUTS
1600 .\"O was specified in
1601 .\"O .IR flags ,
1602 .\"O but the kernel was not configured with the
1603 .\"O .B CONFIG_UTS
1604 .\"O option.
1605 .I flags
1606 ¤Ë
1607 .B CLONE_NEWUTS
1608 ¤¬»ØÄꤵ¤ì¤¿¤¬¡¢¥«¡¼¥Í¥ë¤Ç¥ª¥×¥·¥ç¥ó
1609 .B CONFIG_UTS
1610 ¤¬Í­¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤Ê¤«¤Ã¤¿¡£
1611 .TP
1612 .B ENOMEM
1613 .\"O Cannot allocate sufficient memory to allocate a task structure for the
1614 .\"O child, or to copy those parts of the caller's context that need to be
1615 .\"O copied.
1616 »Ò¥×¥í¥»¥¹¤Î¤¿¤á¤Ë³ÎÊݤ¹¤Ù¤­¥¿¥¹¥¯¹½Â¤ÂΤ䡢¸Æ¤Ó½Ð¤·¸µ¤Î¥³¥ó¥Æ¥­¥¹¥È¤Î
1617 °ìÉô¤ò¥³¥Ô¡¼¤¹¤ë¤Î¤ËɬÍפʥá¥â¥ê¤ò½½Ê¬¤Ë³ä¤êÅö¤Æ¤ë¤³¤È¤¬¤Ç¤­¤Ê¤¤¡£
1618 .TP
1619 .B EPERM
1620 .\"O .BR CLONE_NEWIPC ,
1621 .\"O .BR CLONE_NEWNET ,
1622 .\"O .BR CLONE_NEWNS ,
1623 .\"O .BR CLONE_NEWPID ,
1624 .\"O or
1625 .\"O .BR CLONE_NEWUTS
1626 .\"O was specified by an unprivileged process (process without \fBCAP_SYS_ADMIN\fP).
1627 ÈóÆø¢¥×¥í¥»¥¹ (\fBCAP_SYS_ADMIN\fP ¤ò»ý¤¿¤Ê¤¤¥×¥í¥»¥¹) ¤¬
1628 .BR CLONE_NEWIPC ,
1629 .BR CLONE_NEWNET ,
1630 .BR CLONE_NEWNS ,
1631 .BR CLONE_NEWPID ,
1632 .BR CLONE_NEWUTS
1633 ¤ò»ØÄꤷ¤¿¡£
1634 .TP
1635 .B EPERM
1636 .\"O .B CLONE_PID
1637 .\"O was specified by a process other than process 0.
1638 PID ¤¬ 0 °Ê³°¤Î¥×¥í¥»¥¹¤Ë¤è¤Ã¤Æ
1639 .B CLONE_PID
1640 ¤¬»ØÄꤵ¤ì¤¿¡£
1641 .\"O .SH VERSIONS
1642 .SH ¥Ð¡¼¥¸¥ç¥ó
1643 .\"O There is no entry for
1644 .\"O .BR clone ()
1645 .\"O in libc5.
1646 .\"O glibc2 provides
1647 .\"O .BR clone ()
1648 .\"O as described in this manual page.
1649 libc5 ¤Ë¤Ï
1650 .BR clone ()
1651 ¤Ï¤Ê¤¤¡£glibc2 ¤Ç¤Ï
1652 .BR clone ()
1653 ¤¬Ä󶡤µ¤ì¤Æ¤ª¤ê¡¢¤³¤Î¥Þ¥Ë¥å¥¢¥ë¥Ú¡¼¥¸¤Ëµ­ºÜ¤ÎÄ̤ê¤Ç¤¢¤ë¡£
1654 .\"O .SH "CONFORMING TO"
1655 .SH ½àµò
1656 .\"O The
1657 .\"O .BR clone ()
1658 .\"O and
1659 .\"O .B sys_clone
1660 .\"O calls are Linux-specific and should not be used in programs
1661 .\"O intended to be portable.
1662 .BR clone ()
1663 ¤È
1664 .B sys_clone
1665 ¥³¡¼¥ë¤Ï Linux ÆÃÍ­¤Ç¤¢¤ê¡¢°Ü¿¢¤ò¹Íθ¤·¤¿¥×¥í¥°¥é¥à¤Ç¤Ï»ÈÍѤ¹¤Ù¤­
1666 ¤Ç¤Ï¤Ê¤¤¡£
1667 .\"O .SH NOTES
1668 .SH Ãí°Õ
1669 .\"O In the kernel 2.4.x series,
1670 .\"O .B CLONE_THREAD
1671 .\"O generally does not make the parent of the new thread the same
1672 .\"O as the parent of the calling process.
1673 .\"O However, for kernel versions 2.4.7 to 2.4.18 the
1674 .\"O .B CLONE_THREAD
1675 .\"O flag implied the
1676 .\"O .B CLONE_PARENT
1677 .\"O flag (as in kernel 2.6).
1678 ¥«¡¼¥Í¥ë 2.4.x ·ÏÎó¤Ç¤Ï¡¢°ìÈÌŪ¤Ë¤Ï
1679 .B CLONE_THREAD
1680 ¥Õ¥é¥°¤ò»ØÄꤷ¤Æ¤â¿·¤·¤¤¥¹¥ì¥Ã¥É¤Î¿Æ¤ò
1681 ¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Î¿Æ¤ÈƱ¤¸¤Ë¤Ï¤·¤Ê¤¤¡£
1682 ¤·¤«¤·¡¢¥Ð¡¼¥¸¥ç¥ó 2.4.7¡Á2.4.18 ¤Î¥«¡¼¥Í¥ë¤Ç¤Ï¡¢
1683 (¥«¡¼¥Í¥ë 2.6 ¤ÈƱ¤¸¤è¤¦¤Ë) CLONE_THREAD ¥Õ¥é¥°¤ò»ØÄꤹ¤ë¤È¡¢
1684 °ÅÌۤΤ¦¤Á¤Ë CLONE_PARENT ¥Õ¥é¥°¤ò»ØÄꤷ¤¿¤³¤È¤Ë¤Ê¤ë¡£
1685
1686 .\"O For a while there was
1687 .\"O .B CLONE_DETACHED
1688 .\"O (introduced in 2.5.32):
1689 .\"O parent wants no child-exit signal.
1690 .\"O In 2.6.2 the need to give this
1691 .\"O together with
1692 .\"O .B CLONE_THREAD
1693 .\"O disappeared.
1694 .\"O This flag is still defined, but has no effect.
1695 .B CLONE_DETACHED
1696 ¤È¤¤¤¦¥Õ¥é¥°¤¬¡¢2.5.32 ¤ÇƳÆþ¤µ¤ì¤Æ°ÊÍ褷¤Ð¤é¤¯¤Î´Ö¸ºß¤·¤¿¡£
1697 ¤³¤Î¥Õ¥é¥°¤Ï¿Æ¥×¥í¥»¥¹¤¬»Ò¥×¥í¥»¥¹½ªÎ»¤Î¥·¥°¥Ê¥ë¤òɬÍפȤ·¤Ê¤¤¤³¤È¤ò
1698 ɽ¤¹¤â¤Î¤Ç¤¢¤ë¡£
1699 2.6.2 ¤Ç¡¢ CLONE_DETATCHED ¤ò CLONE_THREAD ¤È°ì½ï¤Ë»ØÄꤹ¤ëɬÍפϤʤ¯¤Ê¤Ã¤¿¡£
1700 ¤³¤Î¥Õ¥é¥°¤Ï¤Þ¤ÀÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤¬¡¢²¿¤Î¸ú²Ì¤â¤Ê¤¤¡£
1701
1702 .\"O On i386,
1703 .\"O .BR clone ()
1704 .\"O should not be called through vsyscall, but directly through
1705 .\"O .IR "int $0x80" .
1706 i386 ¾å¤Ç¤Ï¡¢
1707 .BR clone ()
1708 ¤Ï vsyscall ·Ðͳ¤Ç¤Ï¤Ê¤¯¡¢Ä¾ÀÜ
1709 .I "int $0x80"
1710 ·Ðͳ¤Ç¸Æ¤Ó½Ð¤¹¤Ù¤­¤Ç¤¢¤ë¡£
1711
1712 .\"O On ia64, a different system call is used:
1713 ia64 ¤Ç¤Ï¡¢Ê̤Υ·¥¹¥Æ¥à¥³¡¼¥ë¤¬»ÈÍѤµ¤ì¤ë:
1714 .nf
1715
1716 .BI "int __clone2(int (*" "fn" ")(void *), "
1717 .BI "             void *" child_stack_base ", size_t " stack_size ,
1718 .BI "             int " flags ", void *" "arg" ", ... "
1719 .BI "          /* pid_t *" ptid ", struct user_desc *" tls \
1720 ", pid_t *" ctid " */ );"
1721 .fi
1722 .PP
1723 .\"O The
1724 .\"O .BR __clone2 ()
1725 .\"O system call operates in the same way as
1726 .\"O .BR clone (),
1727 .\"O except that
1728 .\"O .I child_stack_base
1729 .\"O points to the lowest address of the child's stack area,
1730 .\"O and
1731 .\"O .I stack_size
1732 .\"O specifies the size of the stack pointed to by
1733 .\"O .IR child_stack_base .
1734 .BR __clone2 ()
1735 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï
1736 .BR clone ()
1737 ¤ÈƱ¤¸¤è¤¦¤ËÆ°ºî¤¹¤ë¤¬¡¢°Ê²¼¤ÎÅÀ¤¬°Û¤Ê¤ë:
1738 .I child_stack_base
1739 ¤Ï»Ò¥×¥í¥»¥¹¤Î¥¹¥¿¥Ã¥¯¥¨¥ê¥¢¤ÎºÇ¾®¤Î¥¢¥É¥ì¥¹¤ò»Ø¤·¡¢
1740 .I stack_size
1741 ¤Ï
1742 .I child_stack_base
1743 ¤¬»Ø¤·¼¨¤¹¥¹¥¿¥Ã¥¯¥¨¥ê¥¢¤ÎÂ礭¤µ¤ò¼¨¤¹¡£
1744 .\"O .SH BUGS
1745 .SH ¥Ð¥°
1746 .\"O Versions of the GNU C library that include the NPTL threading library
1747 .\"O contain a wrapper function for
1748 .\"O .BR getpid (2)
1749 .\"O that performs caching of PIDs.
1750 NPTL ¥¹¥ì¥Ã¥É¡¦¥é¥¤¥Ö¥é¥ê¤ò´Þ¤ó¤Ç¤¤¤ë GNU C ¥é¥¤¥Ö¥é¥ê¤Î¤¤¤¯¤Ä¤«¤Î¥Ð¡¼¥¸¥ç¥ó
1751 ¤Ë¤Ï¡¢
1752 .BR getpid (2)
1753 ¤Î¥é¥Ã¥Ñ¡¼´Ø¿ô¤¬´Þ¤Þ¤ì¤Æ¤ª¤ê¡¢¤³¤Î¥é¥Ã¥Ñ¡¼´Ø¿ô¤Ï PID ¤ò¥­¥ã¥Ã¥·¥å¤¹¤ë¡£
1754 .\"O This caching relies on support in the glibc wrapper for
1755 .\"O .BR clone (),
1756 .\"O but as currently implemented,
1757 .\"O the cache may not be up to date in some circumstances.
1758 ¤³¤Î¥­¥ã¥Ã¥·¥å½èÍý¤¬Àµ¤·¤¯Æ°ºî¤¹¤ë¤¿¤á¤Ë¤Ï glibc ¤Î
1759 .BR clone (2)
1760 ¤Î¥é¥Ã¥Ñ¡¼´Ø¿ô¤Ç¤Î½õ¤±¤¬É¬ÍפÀ¤¬¡¢¸½¾õ¤Î¼ÂÁõ¤Ç¤Ï¡¢
1761 ¤¢¤ë¾õ¶·²¼¤Ë¤ª¤¤¤Æ¥­¥ã¥Ã¥·¥å¤¬ºÇ¿·¤È¤Ê¤é¤Ê¤¤²ÄǽÀ­¤¬¤¢¤ë¡£
1762 .\"O In particular,
1763 .\"O if a signal is delivered to the child immediately after the
1764 .\"O .BR clone ()
1765 .\"O call, then a call to
1766 .\"O .BR getpid ()
1767 .\"O in a handler for the signal may return the PID
1768 .\"O of the calling process ("the parent"),
1769 .\"O if the clone wrapper has not yet had a chance to update the PID
1770 .\"O cache in the child.
1771 Æäˡ¢
1772 .BR clone ()
1773 ¤Î¸Æ¤Ó½Ð¤·Ä¾¸å¤Ë¥·¥°¥Ê¥ë¤¬»Ò¥×¥í¥»¥¹¤ËÇÛÁ÷¤µ¤ì¤¿¾ì¹ç¤Ë¡¢
1774 ¤½¤Î¥·¥°¥Ê¥ë¤ËÂФ¹¤ë¥Ï¥ó¥É¥éÆâ¤Ç
1775 .BR getpid ()
1776 ¤ò¸Æ¤Ó½Ð¤¹¤È¡¢¤½¤ì¤Þ¤Ç¤Ë clone ¤Î¥é¥Ã¥Ñ¡¼´Ø¿ô¤¬»Ò¥×¥í¥»¥¹¤Î PID ¥­¥ã¥Ã¥·¥å¤ò
1777 ¹¹¿·¤¹¤ëµ¡²ñ¤¬ÆÀ¤é¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹ ("¿Æ¥×¥í¥»¥¹") ¤Î PID ¤¬
1778 ÊÖ¤µ¤ì¤ë²ÄǽÀ­¤¬¤¢¤ë¡£
1779 .\"O (This discussion ignores the case where the child was created using
1780 .\"O .BR CLONE_THREAD ,
1781 .\"O when
1782 .\"O .BR getpid ()
1783 .\"O .I should
1784 .\"O return the same value in the child and in the process that called
1785 .\"O .BR clone (),
1786 .\"O since the caller and the child are in the same thread group.
1787 .\"O The stale-cache problem also does not occur if the
1788 .\"O .I flags
1789 .\"O argument includes
1790 .\"O .BR CLONE_VM .)
1791 (¤³¤ÎµÄÏÀ¤Ç¤Ï¡¢»Ò¥×¥í¥»¥¹¤¬
1792 .B CLONE_THREAD
1793 ¤ò»È¤Ã¤ÆºîÀ®¤µ¤ì¤¿¾ì¹ç¤Î¤³¤È¤Ï̵»ë¤·¤Æ¤¤¤ë¡£
1794 »Ò¥×¥í¥»¥¹¤¬
1795 .B CLONE_THREAD
1796 ¤òºî¤Ã¤ÆºîÀ®¤µ¤ì¤¿¾ì¹ç¤Ë¤Ï¡¢
1797 ¸Æ¤Ó½Ð¤·¸µ¤È»Ò¥×¥í¥»¥¹¤ÏƱ¤¸¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Ë°¤¹¤Î¤Ç¡¢
1798 .BR getpid ()
1799 ¤Ï»Ò¥×¥í¥»¥¹¤È
1800 .BR clone ()
1801 ¤ò¸Æ¤Ó½Ð¤·¤¿¥×¥í¥»¥¹¤ÇƱ¤¸ÃͤòÊÖ¤¹¤Î¤¬¡ÖÀµ¤·¤¤¡×¡£
1802 ¥­¥ã¥Ã¥·¥å¤¬ºÇ¿·¤È¤Ê¤é¤Ê¤¤ÌäÂê (stale-cache problem) ¤Ï¡¢
1803 .I flags
1804 ¤Ë
1805 .B CLONE_VM
1806 ¤¬´Þ¤Þ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤âȯÀ¸¤·¤Ê¤¤¡£)
1807 .\"O To get the truth, it may be necessary to use code such as the following:
1808 ËÜÅö¤ÎÃͤòÆÀ¤ë¤¿¤á¤Ë¤Ï¡¢¼¡¤Î¤è¤¦¤Ê¥³¡¼¥É¤ò»È¤¦É¬Íפ¬¤¢¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
1809 .nf
1810
1811     #include <syscall.h>
1812
1813     pid_t mypid;
1814
1815     mypid = syscall(SYS_getpid);
1816 .fi
1817 .\" See also the following bug reports
1818 .\" https://bugzilla.redhat.com/show_bug.cgi?id=417521
1819 .\" http://sourceware.org/bugzilla/show_bug.cgi?id=6910
1820 .\"O .SH "SEE ALSO"
1821 .SH ´ØÏ¢¹àÌÜ
1822 .BR fork (2),
1823 .BR futex (2),
1824 .BR getpid (2),
1825 .BR gettid (2),
1826 .BR set_thread_area (2),
1827 .BR set_tid_address (2),
1828 .BR tkill (2),
1829 .BR unshare (2),
1830 .BR wait (2),
1831 .BR capabilities (7),
1832 .BR pthreads (7)