1 .\" Hey Emacs! This file is -*- nroff -*- source.
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
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.
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
61 .\"WORD: capability ¥±¡¼¥Ñ¥Ó¥ê¥Æ¥£
62 .\"WORD: pending signals ½èÍýÂÔ¤Á¥·¥°¥Ê¥ë
63 .\"WORD: namespace ̾Á°¶õ´Ö
65 .TH CLONE 2 2010-11-01 "Linux" "Linux Programmer's Manual"
67 .\"O clone, __clone2 \- create a child process
69 clone, __clone2 \- »Ò¥×¥í¥»¥¹¤òºîÀ®¤¹¤ë
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
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 " */ );"
87 .\"O creates a new process, in a manner similar to
89 .\"O It is actually a library function layered on top of the underlying
91 .\"O system call, hereinafter referred to as
95 .\"O is given toward the end of this page.
99 ¤ÈƱ¤¸¤è¤¦¤ÊÊýË¡¤Ç¿·¤·¤¤¥×¥í¥»¥¹¤òºîÀ®¤¹¤ë¡£
101 ¤Ë¤Ï¡¢¥é¥¤¥Ö¥é¥ê´Ø¿ô¤È¤½¤Î²¼Áؤˤ¢¤¿¤ë
103 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤¬Â¸ºß¤¹¤ë¡£°Ê²¼¤ÎÀâÌÀ¤Ç¤Ï¡¢¥·¥¹¥Æ¥à¥³¡¼¥ë¤ÎÊý¤ò
107 ¤Ë´Ø¤¹¤ëÀâÌÀ¤Ï¤³¤Î¥Þ¥Ë¥å¥¢¥ë¤ÎºÇ¸å¤ÎÊý¤Ë¤¢¤ë¡£
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
121 ¤È¤Ï°Û¤Ê¤ê¡¢¤³¤ì¤é¤Î¥³¡¼¥ë¤Ç¤Ï¡¢»Ò¥×¥í¥»¥¹ (child process)
122 ¤È¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤È¤¬¡¢¥á¥â¥ê¶õ´Ö¡¢
123 ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Î¥Æ¡¼¥Ö¥ë¡¢¥·¥°¥Ê¥ë¡¦¥Ï¥ó¥É¥é¤Î¥Æ¡¼¥Ö¥ë¤Ê¤É¤Î
124 ¼Â¹Ô¥³¥ó¥Æ¥¥¹¥È¤Î°ìÉô¤ò¶¦Í¤Ç¤¤ë¡£
125 (¤³¤Î¥Þ¥Ë¥å¥¢¥ë¤Ë¤ª¤±¤ë¡Ö¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¡×¤Ï¡¢Ä̾ï¤Ï
126 ¡Ö¿Æ¥×¥í¥»¥¹¡×¤È°ìÃפ¹¤ë¡£Ã¢¤·¡¢¸å½Ò¤Î
132 .\"O is to implement threads: multiple threads of control in a program that
133 .\"O run concurrently in a shared memory space.
135 ¤Î¼çÍפʻÈÍÑË¡¤Ï¥¹¥ì¥Ã¥É (threads) ¤ò¼ÂÁõ¤¹¤ë¤³¤È¤Ç¤¢¤ë:
136 °ì¤Ä¤Î¥×¥í¥°¥é¥à¤ÎÃæ¤ÎÊ£¿ô¤Î¥¹¥ì¥Ã¥É¤Ï¶¦Í¤µ¤ì¤¿¥á¥â¥ê¶õ´Ö¤Ç
139 .\"O When the child process is created with
141 .\"O it executes the function
144 .\"O (This differs from
146 .\"O where execution continues in the child from the point
152 .\"O argument is a pointer to a function that is called by the child
153 .\"O process at the beginning of its execution.
156 .\"O argument is passed to the
160 ¤Ç»Ò¥×¥í¥»¥¹¤¬ºîÀ®¤µ¤ì¤¿»þ¤Ë¡¢ºîÀ®¤µ¤ì¤¿»Ò¥×¥í¥»¥¹¤Ï´Ø¿ô
169 ¤¬¸Æ¤Ó½Ð¤µ¤ì¤¿¾ì½ê¤«¤é¼Â¹Ô¤ò³¤±¤ë¡£)
171 °ú¤¿ô¤Ï¡¢»Ò¥×¥í¥»¥¹¤¬¼Â¹Ô¤ò»Ï¤á¤ë»þ¤Ë»Ò¥×¥í¥»¥¹¤¬¸Æ¤Ó½Ð¤¹
172 ´Ø¿ô¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£
180 .\"O function application returns, the child process terminates.
181 .\"O The integer returned by
183 .\"O is the exit code for the child process.
184 .\"O The child process may also terminate explicitly by calling
186 .\"O or after receiving a fatal signal.
188 ´Ø¿ô¤¬½ªÎ»¤¹¤ë¤È¡¢»Ò¥×¥í¥»¥¹¤Ï½ªÎ»¤¹¤ë¡£
190 ¤Ë¤è¤Ã¤ÆÊÖ¤µ¤ì¤¿À°¿ô¤¬»Ò¥×¥í¥»¥¹¤Î½ªÎ»¥³¡¼¥É¤È¤Ê¤ë¡£
193 ¤ò¸Æ¤ó¤ÇÌÀ¼¨Åª¤Ë½ªÎ»¤¹¤ë¤³¤È¤â¤¢¤ë¤·¡¢Ã×̿Ū¤Ê¥·¥°¥Ê¥ë¤ò¼õ¿®¤·¤¿
194 ¾ì¹ç¤Ë½ªÎ»¤¹¤ë¤³¤È¤â¤¢¤ë¡£
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
207 °ú¤¿ô¤Ï¡¢»Ò¥×¥í¥»¥¹¤Ë¤è¤Ã¤Æ»ÈÍѤµ¤ì¤ë¥¹¥¿¥Ã¥¯¤Î°ÌÃÖ¤ò»ØÄꤹ¤ë¡£
208 »Ò¥×¥í¥»¥¹¤È¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Ï¥á¥â¥ê¤ò¶¦Í¤¹¤ë¤³¤È¤¬¤¢¤ë¤¿¤á¡¢
209 »Ò¥×¥í¥»¥¹¤Ï¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ÈƱ¤¸¥¹¥¿¥Ã¥¯¤Ç¼Â¹Ô¤¹¤ë¤³¤È¤¬¤Ç¤¤Ê¤¤¡£
210 ¤³¤Î¤¿¤á¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Ï»Ò¥×¥í¥»¥¹¤Î¥¹¥¿¥Ã¥¯¤Î¤¿¤á¤Î¥á¥â¥ê¶õ´Ö¤ò
211 ÍÑ°Õ¤·¤Æ¡¢¤³¤Î¶õ´Ö¤Ø¤Î¥Ý¥¤¥ó¥¿¤ò
213 ¤ØÅϤµ¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
214 .\"O Stacks grow downward on all processors that run Linux
215 .\"O (except the HP PA processors), so
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 ¥¹¥¿¥Ã¥¯¤Ï²¼Êý (¥¢¥É¥ì¥¹¤¬¾®¤µ¤¤Êý¸þ) ¤Ø¤È¿¤Ó¤ë¡£¤³¤Î¤¿¤á¡¢ÉáÄ̤Ï
222 ¤Ï»Ò¥×¥í¥»¥¹¤Î¥¹¥¿¥Ã¥¯¤Î¤¿¤á¤ËÍÑ°Õ¤·¤¿¥á¥â¥ê¶õ´Ö¤Î°ìÈÖÂ礤¤
223 ¥¢¥É¥ì¥¹¤ò»Ø¤¹¤è¤¦¤Ë¤¹¤ë¡£
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
232 .\"O then the parent process must specify the
236 .\"O options when waiting for the child with
238 .\"O If no signal is specified, then the parent process is not signaled
239 .\"O when the child terminates.
241 ¤Î²¼°Ì 1 ¥Ð¥¤¥È¤Ï»Ò¥×¥í¥»¥¹¤¬»à¤ó¤À¾ì¹ç¤Ë¿Æ¥×¥í¥»¥¹¤Ø¤ÈÁ÷¤é¤ì¤ë
242 .I "½ªÎ»¥·¥°¥Ê¥ë (termination signal)"
243 ¤ÎÈÖ¹æ¤ò»ØÄꤹ¤ë¡£¤³¤Î¥·¥°¥Ê¥ë¤È¤·¤Æ
245 °Ê³°¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¡¢¿Æ¥×¥í¥»¥¹¤Ï¡¢
247 ¤Ç»Ò¥×¥í¥»¥¹¤òÂԤĺݤˡ¢¥ª¥×¥·¥ç¥ó¤È¤·¤Æ
251 ¤ò»ØÄꤷ¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
252 ¤É¤Î¥·¥°¥Ê¥ë¤â»ØÄꤵ¤ì¤Ê¤«¤Ã¤¿¾ì¹ç¡¢»Ò¥×¥í¥»¥¹¤¬½ªÎ»¤·¤¿»þ¤Ë¿Æ¥×¥í¥»¥¹
253 ¤Ë¥·¥°¥Ê¥ë¤ÏÁ÷¤é¤ì¤Ê¤¤¡£
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:
260 ¤Ë¤Ï¡¢°Ê²¼¤ÎÄê¿ô¤Î¤¦¤Á 0¸Ä°Ê¾å¤ò¥Ó¥Ã¥ÈËè¤ÎÏÀÍýÏ (bitwise-or)
261 ¤ò¤È¤Ã¤¿¤â¤Î¤ò»ØÄê¤Ç¤¤ë¡£¤³¤ì¤é¤ÎÄê¿ô¤Ï¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤È
262 »Ò¥×¥í¥»¥¹¤Î´Ö¤Ç²¿¤ò¶¦Í¤¹¤ë¤«¤ò»ØÄꤹ¤ë:
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
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)
273 .\"O This is used by threading libraries.
274 »Ò¥×¥í¥»¥¹¤¬½ªÎ»¤·¤¿¤È¤¤Ë»Ò¥×¥í¥»¥¹¤Î¥á¥â¥êÆâ¤Î
276 ¤¬»Ø¤¹¾ì½ê¤Ë¤¢¤ë»Ò¥×¥í¥»¥¹¤Î¥¹¥ì¥Ã¥É ID ¤ò¾Ãµî¤·¡¢
277 ¤½¤Î¥¢¥É¥ì¥¹¤Ç futex ¤ò wake (µ¯¾²) ¤µ¤»¤ë¡£
279 .BR set_tid_address (2)
280 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤ÇÊѹ¹¤¹¤ë¤³¤È¤¬¤Ç¤¤ë¡£
281 ¤³¤Îµ¡Ç½¤Ï¥¹¥ì¥Ã¥É¥é¥¤¥Ö¥é¥ê¤Ç»ÈÍѤµ¤ì¤ë¡£
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
287 .\"O in child memory.
288 »Ò¥×¥í¥»¥¹¤Î¥á¥â¥êÆâ¤Î
290 ¤¬»Ø¤¹¾ì½ê¤Ë»Ò¥×¥í¥»¥¹¤Î¥¹¥ì¥Ã¥É ID ¤ò³ÊǼ¤¹¤ë¡£
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
303 .\"O operation), the other process is also affected.
305 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤È»Ò¥×¥í¥»¥¹¤Ï¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Î
307 ¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤È¤½¤Î»Ò¥×¥í¥»¥¹¤Î°ìÊý¤¬ºîÀ®¤·¤¿
308 ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ï¡¢¤â¤¦°ìÊý¤Ë¤ª¤¤¤Æ¤â͸ú¤Ç¤¢¤ë¡£
309 Ʊ¤¸¤è¤¦¤Ë¡¢°ìÊý¤Î¥×¥í¥»¥¹¤¬¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤òÊĤ¸¤¿¤ê¡¢
312 Áàºî¤ò»È¤Ã¤Æ) ¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ë´ØÏ¢¤¹¤ë¥Õ¥é¥°¤òÊѹ¹¤·¤¿¤ê¤¹¤ë¤È¡¢
313 ¤â¤¦°ìÊý¤Î¥×¥í¥»¥¹¤Ë¤â±Æ¶Á¤¹¤ë¡£
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
320 .\"O (The duplicated file descriptors in the child refer to the
321 .\"O same open file descriptions (see
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.
329 ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢»Ò¥×¥í¥»¥¹¤Ï¡¢
331 ¤¬¼Â¹Ô¤µ¤ì¤¿»þÅÀ¤Ç¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤¬¥ª¡¼¥×¥ó¤·¤Æ¤¤¤ëÁ´¤Æ¤Î
332 ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Î¥³¥Ô¡¼¤ò·Ñ¾µ¤¹¤ë
333 (»Ò¥×¥í¥»¥¹¤ÎÊ£À½¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ï¡¢
334 Âбþ¤¹¤ë¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤È
338 ¤³¤ì°Ê¹ß¤Ë¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤È»Ò¥×¥í¥»¥¹¤Î°ìÊý¤¬
339 ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ÎÁàºî (¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Î
340 ¥ª¡¼¥×¥ó¡¦¥¯¥í¡¼¥º¤ä¡¢¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¦¥Õ¥é¥°¤ÎÊѹ¹)
341 ¤ò¹Ô¤Ã¤Æ¤â¡¢¤â¤¦°ìÊý¤Î¥×¥í¥»¥¹¤Ë¤Ï±Æ¶Á¤òÍ¿¤¨¤Ê¤¤¡£
346 .\"O is set, the caller and the child process share the same file system
348 .\"O This includes the root of the file system, the current
349 .\"O working directory, and the umask.
355 .\"O performed by the calling process or the child process also affects the
358 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤È»Ò¥×¥í¥»¥¹¤¬Æ±¤¸¥Õ¥¡¥¤¥ë¡¦¥·¥¹¥Æ¥à
359 ¾ðÊó¤ò¶¦Í¤¹¤ë¡£¥Õ¥¡¥¤¥ë¡¦¥·¥¹¥Æ¥à¾ðÊó¤Ï¡¢¥Õ¥¡¥¤¥ë¡¦¥·¥¹¥Æ¥à¤Î¥ë¡¼¥È (root)¡¢
360 ¥«¥ì¥ó¥È¡¦¥ï¡¼¥¥ó¥°¡¦¥Ç¥£¥ì¥¯¥È¥ê (current working directory)
361 ¤ä umask ¤Ê¤É¤Ç¤¢¤ë¡£
362 ¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ä»Ò¥×¥í¥»¥¹¤Î¤É¤Á¤é¤«°ìÊý¤Ë¤è¤Ã¤Æ
366 ¤¬¸Æ¤Ó½Ð¤µ¤ì¤ë¤È¡¢¤â¤¦°ìÊý¤Î¥×¥í¥»¥¹¤Ë¤â±Æ¶Á¤¬µÚ¤Ö¡£
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
378 .\"O performed later by one of the processes do not affect the other process.
380 ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢»Ò¥×¥í¥»¥¹¤Ï¡¢
382 ¤¬¼Â¹Ô¤µ¤ì¤¿»þÅÀ¤Ç¤Î¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î¥Õ¥¡¥¤¥ë¡¦¥·¥¹¥Æ¥à¾ðÊó¤Î¥³¥Ô¡¼¤ò
384 ¤³¤ì°Ê¹ß¤Ï¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤È»Ò¥×¥í¥»¥¹¤Î°ìÊý¤¬
388 ¤ò¸Æ¤Ó½Ð¤·¤Æ¤â¡¢¤â¤¦°ìÊý¤Î¥×¥í¥»¥¹¤Ë¤Ï±Æ¶Á¤òÍ¿¤¨¤Ê¤¤¡£
390 .\"O .BR CLONE_IO " (since Linux 2.6.25)"
391 .BR CLONE_IO " (Linux 2.6.25 °Ê¹ß)"
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
398 .\"O the new process has its own I/O context.
400 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢¿·¤·¤¤¥×¥í¥»¥¹¤Ï¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤È
401 I/O ¥³¥ó¥Æ¥¥¹¥È¤ò¶¦Í¤¹¤ë¡£
402 ¤³¤Î¥Õ¥é¥°¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ë¤Ï¡¢
404 ¤Î¾ì¹ç¤ÈƱÍÍ) ¿·¤·¤¤¥×¥í¥»¥¹¤Ï¼«Ê¬ÀìÍѤΠI/O ¥³¥ó¥Æ¥¥¹¥È¤ò»ý¤Ä¡£
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
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 ¤ò¼Â¹Ô¤·¤Æ¤¤¤ë¾ì¹ç
436 ¤òÍøÍѤ¹¤ë¤³¤È¤Ç I/O Àǽ¤òÎɤ¯¤¹¤ë¤³¤È¤¬¤Ç¤¤ë¡£
439 .\"O If the kernel is not configured with the
441 .\"O option, this flag is a no-op.
444 ¥ª¥×¥·¥ç¥óÉÕ¤¤Ç¤Ê¤¤¾ì¹ç¡¢
445 ¤³¤Î¥Õ¥é¥°¤Ï²¿¤Î°ÕÌ£¤â»ý¤¿¤Ê¤¤¡£
447 .\"O .BR CLONE_NEWIPC " (since Linux 2.6.19)"
448 .BR CLONE_NEWIPC " (Linux 2.6.19 °Ê¹ß)"
451 .\"O is set, then create the process in a new IPC namespace.
452 .\"O If this flag is not set, then (as with
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.
458 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢¿·¤·¤¤ IPC ̾Á°¶õ´Ö (namespace) ¤Ç¥×¥í¥»¥¹¤òºîÀ®¤¹¤ë¡£
459 ¤³¤Î¥Õ¥é¥°¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢
461 ¤Î¾ì¹ç¤ÈƱÍÍ) ¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ÈƱ¤¸ IPC ̾Á°¶õ´Ö¤Ç¥×¥í¥»¥¹¤¬
463 ¤³¤Î¥Õ¥é¥°¤Ï¡¢¥³¥ó¥Æ¥Ê¤Î¼ÂÁõ¤Ç¤Î»ÈÍѤò°Õ¿Þ¤·¤ÆÍÑ°Õ¤µ¤ì¤¿¤â¤Î¤Ç¤¢¤ë¡£
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
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) ¤Î
477 (System V IPC ¥ª¥Ö¥¸¥§¥¯¥È¤Ï
481 ¤ò»È¤Ã¤ÆºîÀ®¤µ¤ì¤ë)¡£
482 ¤¢¤ë IPC ̾Á°¶õ´Ö¤ËºîÀ®¤µ¤ì¤¿¥ª¥Ö¥¸¥§¥¯¥È¤Ï¡¢
483 ¤½¤Î̾Á°¶õ´Ö¤Î¥á¥ó¥Ð¡¼¤Ç¤¢¤ë¾¤Î¤¹¤Ù¤Æ¤Î¥×¥í¥»¥¹¤«¤é¤â¸«¤¨¤ë¤¬¡¢
484 °ã¤¦ IPC ̾Á°¶õ´Ö¤Î¥×¥í¥»¥¹¤«¤é¤Ï¸«¤¨¤Ê¤¤¡£
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 ¥ª¥Ö¥¸¥§¥¯¥È¤Ï¼«Æ°Åª¤ËÇË´þ¤µ¤ì¤ë¡£
493 .\"O Use of this flag requires: a kernel configured with the
494 .\"O .B CONFIG_SYSVIPC
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 ¤³¤Î¥Õ¥é¥°¤ò»ÈÍѤ¹¤ë¤¿¤á¤Ë¤Ï¡¢
506 ¤ò͸ú¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤³¤È¡¢
508 .RB ( CAP_SYS_ADMIN )
509 ¤ò»ý¤Ã¤Æ¤¤¤ë¤³¤È¤¬É¬ÍפǤ¢¤ë¡£
512 ¤ÈÁȤ߹ç¤ï¤»¤Æ»È¤¦¤³¤È¤Ï¤Ç¤¤Ê¤¤¡£
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 ¤¢¤¿¤ê¤Þ¤Ç¤Ë´°À®¤·¤¿¡£)
522 .\"O is set, then create the process in a new network namespace.
523 .\"O If this flag is not set, then (as with
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.
529 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢¿·¤·¤¤¥Í¥Ã¥È¥ï¡¼¥¯Ì¾Á°¶õ´Ö (network namaspace)
530 ¤Ç¥×¥í¥»¥¹¤òºîÀ®¤¹¤ë¡£
531 ¤³¤Î¥Õ¥é¥°¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢
533 ¤Î¾ì¹ç¤ÈƱÍÍ) ¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ÈƱ¤¸¥Í¥Ã¥È¥ï¡¼¥¯Ì¾Á°¶õ´Ö¤Ç¥×¥í¥»¥¹¤¬
535 ¤³¤Î¥Õ¥é¥°¤Ï¡¢¥³¥ó¥Æ¥Ê¤Î¼ÂÁõ¤Ç¤Î»ÈÍѤò°Õ¿Þ¤·¤ÆÍÑ°Õ¤µ¤ì¤¿¤â¤Î¤Ç¤¢¤ë¡£
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
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 ¥×¥í¥È¥³¥ë¥¹¥¿¥Ã¥¯¡¢
555 ¥Ç¥£¥ì¥¯¥È¥ê¥Ä¥ê¡¼¡¢¥½¥±¥Ã¥È¤Ê¤É¤Ç¤¢¤ë)¡£
556 ʪÍý¥Í¥Ã¥È¥ï¡¼¥¯¥Ç¥Ð¥¤¥¹¤¬½ê°¤Ç¤¤ë¥Í¥Ã¥È¥ï¡¼¥¯Ì¾Á°¶õ´Ö¤Ï°ì¤Ä¤À¤±¤Ç¤¢¤ë¡£
557 ²¾Áۥͥåȥ¥¯¥Ç¥Ð¥¤¥¹ ("veth") ¤Î¥Ú¥¢¤Ë¤è¤ê
558 ¥Ñ¥¤¥×É÷¤ÎÃê¾Ý²½ (abstraction) ¤¬¼Â¸½¤µ¤ì¤Æ¤ª¤ê¡¢
559 ¤³¤ì¤ò»È¤¦¤³¤È¤Ç¡¢¥Í¥Ã¥È¥ï¡¼¥¯Ì¾Á°¶õ´Ö´Ö¤Î¥È¥ó¥Í¥ë¤òºîÀ®¤·¤¿¤ê¡¢
560 Ê̤Î̾Á°¶õ´Ö¤ÎʪÍý¥Í¥Ã¥È¥ï¡¼¥¯¥Ç¥Ð¥¤¥¹¤Ø¤Î¥Ö¥ê¥Ã¥¸¤òºîÀ®¤·¤¿¤ê
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 (¿Æ¥×¥í¥»¥¹¤Î¥Í¥Ã¥È¥ï¡¼¥¯Ì¾Á°¶õ´Ö¤ËÌᤵ¤ì¤ëÌõ¤Ç¤Ï¤Ê¤¤)¡£
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 ¤³¤Î¥Õ¥é¥°¤ò»ÈÍѤ¹¤ë¤¿¤á¤Ë¤Ï¡¢
580 ¤ò͸ú¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤³¤È¡¢
582 .RB ( CAP_SYS_ADMIN )
583 ¤ò»ý¤Ã¤Æ¤¤¤ë¤³¤È¤¬É¬ÍפǤ¢¤ë¡£
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) ¤Ç³«»Ï¤¹¤ë¡£
590 .\"O Every process lives in a mount namespace.
593 .\"O of a process is the data (the set of mounts) describing the file hierarchy
594 .\"O as seen by that process.
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 ¤Î½¸¹ç) ¤Ç¤¢¤ë¡£
607 ¥Õ¥é¥°¤¬¥»¥Ã¥È¤µ¤ì¤º¤Ë
611 ¤¬¸Æ¤Ð¤ì¤ë¤È¡¢»Ò¥×¥í¥»¥¹¤Ï¿Æ¥×¥í¥»¥¹¤ÈƱ¤¸¥Þ¥¦¥ó¥È̾Á°¶õ´Ö¤ËºîÀ®¤µ¤ì¤ë¡£
612 .\"O The system calls
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.
622 ¤¬¸Æ¤Ð¤ì¤ë¤È¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î¥Þ¥¦¥ó¥È̾Á°¶õ´Ö¤¬Êѹ¹¤µ¤ì¡¢¤³¤Î·ë²Ì
623 ¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ÈƱ¤¸Ì¾Á°¶õ´Ö¤Ë¤¤¤ë¥×¥í¥»¥¹¤Ï¤¹¤Ù¤Æ±Æ¶Á¤ò¼õ¤±¤ë¤¬¡¢
624 °Û¤Ê¤ë¥Þ¥¦¥ó¥È̾Á°¶õ´Ö¤Ë¤¤¤ë¥×¥í¥»¥¹¤Ï±Æ¶Á¤ò¼õ¤±¤Ê¤¤¡£
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.
635 ¤¬¸Æ¤Ð¤ì¤ë¤È¡¢clone ¤ÇºîÀ®¤µ¤ì¤¿»Ò¥×¥í¥»¥¹¤Ï¿·¤·¤¤¥Þ¥¦¥ó¥È̾Á°¶õ´Ö¤Ç
636 ³«»Ï¤µ¤ì¤ë¡£¿·¤·¤¤Ì¾Á°¶õ´Ö¤Ï¿Æ¥×¥í¥»¥¹¤Î̾Á°¶õ´Ö¤Î¥³¥Ô¡¼¤Ç½é´ü²½¤µ¤ì¤ë¡£
638 .\"O Only a privileged process (one having the \fBCAP_SYS_ADMIN\fP capability)
642 .\"O It is not permitted to specify both
649 Æø¢¥×¥í¥»¥¹ (\fBCAP_SYS_ADMIN\fP ¥±¡¼¥Ñ¥Ó¥ê¥Æ¥£¤ò»ý¤Ä¥×¥í¥»¥¹) ¤Î¤ß¤¬
651 ¥Õ¥é¥°¤ò»ØÄꤹ¤ë¤³¤È¤¬¤Ç¤¤ë¡£
658 ¤ÎξÊý¤ò»ØÄꤹ¤ë¤³¤È¤Ï¤Ç¤¤Ê¤¤¡£
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>
667 .\" The primary kernel commit is 30e49c263e36341b60b735cbef5ca37912549264
668 .\" Author: Pavel Emelyanov <xemul@openvz.org>
671 .\"O is set, then create the process in a new PID namespace.
672 .\"O If this flag is not set, then (as with
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.
678 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢¿·¤·¤¤ PID ̾Á°¶õ´Ö¤Ç¥×¥í¥»¥¹¤òºîÀ®¤¹¤ë¡£
679 ¤³¤Î¥Õ¥é¥°¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢
681 ¤Î¾ì¹ç¤ÈƱÍÍ) ¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ÈƱ¤¸ PID ̾Á°¶õ´Ö¤Ç
682 ¥×¥í¥»¥¹¤¬ºîÀ®¤µ¤ì¤ë¡£
683 ¤³¤Î¥Õ¥é¥°¤Ï¡¢¥³¥ó¥Æ¥Ê¤Î¼ÂÁõ¤Ç¤Î»ÈÍѤò°Õ¿Þ¤·¤ÆÍÑ°Õ¤µ¤ì¤¿¤â¤Î¤Ç¤¢¤ë¡£
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
692 .\"O will produce processes with PIDs that are unique within the namespace.
693 PID ̾Á°¶õ´Ö¤Ï¡¢PID ¤Ë´Ø¤·¤ÆʬΥ¤µ¤ì¤¿´Ä¶¤òÄ󶡤¹¤ë¤â¤Î¤Ç¤¢¤ë¡£
694 ¿·¤·¤¤Ì¾Á°¶õ´Ö¤Ë¤ª¤±¤ë PID ¤Ï 1 ¤«¤é»Ï¤Þ¤ê
695 (¤³¤ì¤Ï¥¹¥¿¥ó¥É¥¢¥í¥ó¤Î¥·¥¹¥Æ¥à¤È»÷¤¿¤è¤¦¤Ê´¶¤¸)¡¢
699 ¤ò¸Æ¤Ó½Ð¤¹¤È¡¢¤½¤Î̾Á°¶õ´Ö¤Ç°ì°Õ¤Ê PID ¤ò»ý¤Ã¤¿¥×¥í¥»¥¹¤¬ºîÀ®¤µ¤ì¤ë¡£
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
708 .\"O Unlike the traditional
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 ¿·¤·¤¤Ì¾Á°¶õ´Ö¤ÇºîÀ®¤µ¤ì¤ëºÇ½é¤Î¥×¥í¥»¥¹
715 ¥Õ¥é¥°¤ò»È¤Ã¤ÆºîÀ®¤µ¤ì¤¿¥×¥í¥»¥¹) ¤Î PID ¤Ï 1 ¤Ç¤¢¤ê¡¢
716 ¤³¤Î¥×¥í¥»¥¹¤Ï¤½¤Î̾Á°¶õ´Ö¤Ë¤ª¤±¤ë "init" ¥×¥í¥»¥¹¤È¤Ê¤ë¡£
717 ¤³¤Î̾Á°¶õ´Ö¤Ë¤ª¤¤¤Æ¸É»ù (orphaned) ¤È¤Ê¤Ã¤¿»Ò¥×¥í¥»¥¹¤Ë¤Ä¤¤¤Æ¤Ï¡¢
719 ¤Ç¤Ï¤Ê¤¯¤³¤Î¥×¥í¥»¥¹¤¬¿Æ¥×¥í¥»¥¹¤È¤Ê¤ë¡£
722 ¥×¥í¥»¥¹¤È¤Ï°ã¤¤¡¢PID ̾Á°¶õ´Ö¤Î "init" ¥×¥í¥»¥¹¤Ï½ªÎ» (terminated) ¤¹¤ë
723 ¤³¤È¤¬¤Ç¤¡¢¤½¤Î¾ì¹ç¤Ë¤Ï¡¢¤³¤Î̾Á°¶õ´Ö¤ÎÁ´¤Æ¤Î¥×¥í¥»¥¹¤¬½ªÎ»¤µ¤ì¤ë¡£
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.
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 ¤ÏÂбþ¤¹¤ë̾Á°¶õ´Ö¤Ë¤ª¤¤¤Æ°ì°Õ¤Ç¤¢¤ë¡£
756 ¤ò¸Æ¤Ó½Ð¤¹¤È¡¢¾ï¤Ë¤½¤Î¥×¥í¥»¥¹¤¬Â¸ºß¤·¤Æ¤¤¤ë̾Á°¶õ´Ö¤Ë¤ª¤±¤ë
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
763 .\"O so that tools such as
766 ¿·¤·¤¤Ì¾Á°¶õ´Ö¤ÎºîÀ®¸å¤Ë¤Ï¡¢
769 ¤È¤¤¤Ã¤¿¥Ä¡¼¥ë¤¬Àµ¤·¤¯Æ°ºî¤¹¤ë¤è¤¦¤Ë¡¢
770 ¼«¿È¤Î root ¥Ç¥£¥ì¥¯¥È¥ê¤òÊѹ¹¤·¡¢
772 ¤Ë¿·¤·¤¤ procfs ¥¤¥ó¥¹¥¿¥ó¥¹¤ò¥Þ¥¦¥ó¥È¤¹¤ë¤Î¤¬¤è¤¤¤À¤í¤¦¡£
773 .\" mount -t proc proc /proc
776 .\"O is also included in
778 .\"O then it isn't necessary to change the root directory:
779 .\"O a new procfs instance can be mounted directly over
784 ¤â»ØÄꤵ¤ì¤Æ¤¤¤¿¾ì¹ç¤Ë¤Ï¡¢root ¥Ç¥£¥ì¥¯¥È¥ê¤òÊѹ¹¤¹¤ëɬÍפϤʤ¯¡¢
785 ¤¤¤¤Ê¤ê¿·¤·¤¤ procfs ¥¤¥ó¥¹¥¿¥ó¥¹¤ò
787 ¤Ë¥Þ¥¦¥ó¥È¤¹¤ë¤³¤È¤¬¤Ç¤¤ë¡£)
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 ¤³¤Î¥Õ¥é¥°¤ò»ÈÍѤ¹¤ë¤¿¤á¤Ë¤Ï¡¢
798 ¤ò͸ú¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤³¤È¡¢
800 .RB ( CAP_SYS_ADMIN )
801 ¤ò»ý¤Ã¤Æ¤¤¤ë¤³¤È¤¬É¬ÍפǤ¢¤ë¡£
804 ¤ÈÁȤ߹ç¤ï¤»¤Æ»È¤¦¤³¤È¤Ï¤Ç¤¤Ê¤¤¡£
806 .\"O .BR CLONE_NEWUTS " (since Linux 2.6.19)"
807 .BR CLONE_NEWUTS " (Linux 2.6.19 °Ê¹ß)"
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
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.
819 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢¿·¤·¤¤ UTS ̾Á°¶õ´Ö¤Ç¥×¥í¥»¥¹¤òºîÀ®¤¹¤ë¡£
820 ¿·¤·¤¤ UTS ̾Á°¶õ´Ö¤Î¼±Ê̻Ҥνé´üÃͤϡ¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î
821 UTS ̾Á°¶õ´Ö¤Î¼±Ê̻ҤòÊ£À½¤·¤¿¤â¤Î¤È¤Ê¤ë¡£
822 ¤³¤Î¥Õ¥é¥°¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢
824 ¤Î¾ì¹ç¤ÈƱÍÍ) ¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ÈƱ¤¸ UTS ̾Á°¶õ´Ö¤Ç
825 ¥×¥í¥»¥¹¤¬ºîÀ®¤µ¤ì¤ë¡£
826 ¤³¤Î¥Õ¥é¥°¤Ï¡¢¥³¥ó¥Æ¥Ê¤Î¼ÂÁõ¤Ç¤Î»ÈÍѤò°Õ¿Þ¤·¤ÆÍÑ°Õ¤µ¤ì¤¿¤â¤Î¤Ç¤¢¤ë¡£
828 .\"O A UTS namespace is the set of identifiers returned by
830 .\"O among these, the domain name and the host name can be modified by
831 .\"O .BR setdomainname (2)
834 .\"O .BR sethostname (2),
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.
841 ¤¬ÊÖ¤¹¼±Ê̻Ҥν¸¹ç¤Ç¤¢¤ë¡£
842 ¼±Ê̻ҤȤ·¤Æ¤Ï¥É¥á¥¤¥ó̾¤È¥Û¥¹¥È̾¤¬¤¢¤ê¡¢
844 .BR setdomainname (2),
846 ¤Ç½¤Àµ¤¹¤ë¤³¤È¤¬¤Ç¤¤ë¡£
847 ¤¢¤ë UTS ̾Á°¶õ´Ö¤Ë¤ª¤±¤ë¼±Ê̻ҤÎÊѹ¹¤ÏƱ¤¸Ì¾Á°¶õ´Ö¤Î¾¤Î¤¹¤Ù¤Æ¤Î
848 ¥×¥í¥»¥¹¤Ë¸«¤¨¤ë¤¬¡¢Ê̤ΠUTS ̾Á°¶õ´Ö¤Î¥×¥í¥»¥¹¤Ë¤Ï¸«¤¨¤Ê¤¤¡£
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 ¤³¤Î¥Õ¥é¥°¤ò»ÈÍѤ¹¤ë¤¿¤á¤Ë¤Ï¡¢
857 ¤ò͸ú¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤³¤È¡¢
859 .RB ( CAP_SYS_ADMIN )
860 ¤ò»ý¤Ã¤Æ¤¤¤ë¤³¤È¤¬É¬ÍפǤ¢¤ë¡£
862 .\"O .BR CLONE_PARENT " (since Linux 2.3.12)"
863 .BR CLONE_PARENT " (Linux 2.3.12 °Ê¹ß)"
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.
870 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢¿·¤·¤¤»Ò¶¡¤Î
872 ¤ÇÊÖ¤µ¤ì¤ë) ¿Æ¥×¥í¥»¥¹¤Ï¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î¿Æ¥×¥í¥»¥¹¤ÈƱ¤¸¤Ë¤Ê¤ë¡£
876 .\"O is not set, then (as with
878 .\"O the child's parent is the calling process.
880 ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢
882 ¤ÈƱÍͤË) ¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤¬¤½¤Î»Ò¶¡¤Î¿Æ¤Ë¤Ê¤ë¡£
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
889 .\"O is set, then the parent of the calling process, rather than the
890 .\"O calling process itself, will be signaled.
891 »Ò¶¡¤¬½ªÎ»¤·¤¿»þ¤Ë¥·¥°¥Ê¥ë¤¬Á÷¤é¤ì¤ë¤Î¤Ï
893 ¤¬ÊÖ¤¹¿Æ¥×¥í¥»¥¹¤Ç¤¢¤ëÅÀ¤ËÃí°Õ¤¹¤ë¤³¤È¡£¤³¤Î¤¿¤á
895 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Ç¤Ï¤Ê¤¯¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î
896 ¿Æ¥×¥í¥»¥¹¤Ë¥·¥°¥Ê¥ë¤¬Á÷¤é¤ì¤ë¡£
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
902 .\"O in parent and child memory.
903 .\"O (In Linux 2.5.32-2.5.48 there was a flag
906 ¿Æ¥×¥í¥»¥¹¤È»Ò¥×¥í¥»¥¹¤Î¥á¥â¥êÆâ¤Î
908 ¤¬»Ø¤¹Îΰè¤Ë»Ò¥×¥í¥»¥¹¤Î¥¹¥ì¥Ã¥É ID ¤ò³ÊǼ¤¹¤ë¡£
909 (Linux 2.5.32-2.5.48 ¤Ç¤Ï¡¢
912 ¤È¤¤¤¦¥Õ¥é¥°¤¬Â¸ºß¤·¤¿¡£)
914 .\"O .BR CLONE_PID " (obsolete)"
915 .BR 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.
926 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢»Ò¥×¥í¥»¥¹¤Ï¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ÈƱ¤¸¥×¥í¥»¥¹ ID
927 ¤ÇºîÀ®¤µ¤ì¤ë¡£¤³¤ì¤Ï¥·¥¹¥Æ¥à¤ò¥Ï¥Ã¥¥ó¥°¤¹¤ë¤Î¤Ë¤ÏÊØÍø¤À¤¬¡¢
928 ¤½¤ì°Ê³°¤Ë¤Ï¤¢¤Þ¤ê»È¤ï¤ì¤Ê¤¤¡£ Linux 2.3.21 °Ê¹ß¤Ç¤Ï¡¢
929 ¥·¥¹¥Æ¥à¤Î¥Ö¡¼¥È¥×¥í¥»¥¹ (PID 0) ¤À¤±¤¬¤³¤Î¥Õ¥é¥°¤ò»ØÄê¤Ç¤¤ë¡£
930 Linux 2.5.16 ¤Çºï½ü¤µ¤ì¤¿¡£
935 .\"O is specified, and the calling process is being traced,
936 .\"O then trace the child also (see
937 .\"O .BR ptrace (2)).
939 ¤¬»ØÄꤵ¤ì¡¢¤«¤Ä¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤¬ÄÉÀ× (trace) ¤µ¤ì¤Æ¤¤¤¿¾ì¹ç¡¢»Ò¥×¥í¥»¥¹¤â
944 .\"O .BR CLONE_SETTLS " (since Linux 2.5.32)"
945 .BR CLONE_SETTLS " (Linux 2.5.32 °Ê¹ß)"
948 .\"O argument is the new TLS (Thread Local Storage) descriptor.
950 .\"O .BR set_thread_area (2).)
952 °ú¤¿ô¤Ï¡¢¿·¤·¤¤ TLS (Thread Local Storage) ¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç¤¢¤ë¡£
953 .RB ( set_thread_area (2)
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
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.
972 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤È»Ò¥×¥í¥»¥¹¤ÏƱ¤¸¥·¥°¥Ê¥ë¡¦¥Ï¥ó
973 ¥É¥é¤Î¥Æ¡¼¥Ö¥ë¤ò¶¦Í¤¹¤ë¡£¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Þ¤¿¤Ï»Ò¥×¥í¥»¥¹¤Î¤É¤Á¤é¤«¤¬
975 ¤ò¸Æ¤Ó½Ð¤·¤Æ¥·¥°¥Ê¥ë¤ËÂбþ¤¹¤ëÆ°ºî¤òÊѹ¹¤·¤¿¾ì¹ç¡¢
976 ¤â¤¦°ìÊý¤Î¥×¥í¥»¥¹¤Î¥·¥°¥Ê¥ëÆ°ºî¤âÊѹ¹¤µ¤ì¤ë¡£
977 ⤷¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤È»Ò¥×¥í¥»¥¹¤Ï¡¢
978 ¥×¥í¥»¥¹Ëè¤Ë¡¢¥·¥°¥Ê¥ë¡¦¥Þ¥¹¥¯ (signal mask) ¤È½èÍýÂÔ¤Á¥·¥°¥Ê¥ë¤Î½¸¹ç
979 ¤ò»ý¤Ã¤Æ¤¤¤ë¡£¤³¤Î¤¿¤á¡¢¤¢¤ë¥×¥í¥»¥¹¤Ï¡¢
981 ¤ò»ÈÍѤ·¤Æ¡¢¤â¤¦°ìÊý¤Î¥×¥í¥»¥¹¤Ë±Æ¶Á¤òÍ¿¤¨¤º¤Ë
982 ¥·¥°¥Ê¥ë¤ò¶Ø»ß (block) ¤·¤¿¤êµö²Ä (unblock) ¤·¤¿¤ê¤Ç¤¤ë¡£
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
991 .\"O .BR sigaction (2)
992 .\"O performed later by one of the processes have no effect on the other
995 ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢»Ò¥×¥í¥»¥¹¤Ï
997 ¤¬¼Â¹Ô¤µ¤ì¤¿»þÅÀ¤Ç¤Î¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î¥·¥°¥Ê¥ë¡¦¥Ï¥ó¥É¥é¤Î
998 ¥³¥Ô¡¼¤ò·Ñ¾µ¤¹¤ë¡£¤³¤ì°Ê¹ß¤Ï¡¢°ìÊý¤Î¥×¥í¥»¥¹¤¬
1000 ¤ò¸Æ¤Ó½Ð¤·¤Æ¤â¡¢¤â¤¦°ìÊý¤Î¥×¥í¥»¥¹¤Ë¤Ï±Æ¶Á¤òÍ¿¤¨¤Ê¤¤¡£
1002 .\"O Since Linux 2.6.0-test6,
1004 .\"O must also include
1007 .\"O .B CLONE_SIGHAND
1009 Linux 2.6.0-test6 °Ê¹ß¤Ç¤Ï¡¢
1015 ¤Ë´Þ¤á¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
1017 .\"O .BR CLONE_STOPPED " (since Linux 2.6.0-test2)"
1018 .BR CLONE_STOPPED " (Linux 2.6.0-test2 °Ê¹ß)"
1020 .\"O .B CLONE_STOPPED
1021 .\"O is set, then the child is initially stopped (as though it was sent a
1023 .\"O signal), and must be resumed by sending it a
1027 ¤¬ÀßÄꤵ¤ì¤ë¤È¡¢»Ò¥×¥í¥»¥¹¤ÏºÇ½é
1029 ¥·¥°¥Ê¥ë¤òÁ÷¤é¤ì¤¿¤«¤Î¤è¤¦¤Ë) Ää»ß¤·¤¿¾õÂ֤Ȥʤ롣
1030 »Ò¥×¥í¥»¥¹¤òºÆ³«¤µ¤»¤ë¤Ë¤Ï
1032 ¥·¥°¥Ê¥ë¤òÁ÷¿®¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
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
1043 .\"O .BR CLONE_SYSVSEM " (since Linux 2.5.10)"
1044 .BR CLONE_SYSVSEM " (Linux 2.5.10 °Ê¹ß)"
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.
1053 ¤¬¥»¥Ã¥È¤µ¤ì¤ë¤È¡¢»Ò¥×¥í¥»¥¹¤È¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Ï°ì¤Ä¤Î
1054 System V ¥»¥Þ¥Õ¥©¤Î¥¢¥ó¥É¥¥Ãͥꥹ¥È
1056 »²¾È) ¤ò¶¦Í¤¹¤ë¡£¤³¤Î¥Õ¥é¥°¤¬¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢
1057 »Ò¥×¥í¥»¥¹¤ÏÆȼ«¤Î¥¢¥ó¥É¥¥¥ê¥¹¥È¤ò»ý¤Ä (¥ê¥¹¥È¤Î½é´üÃͤ϶õ¤Ç¤¢¤ë)¡£
1059 .\"O .BR CLONE_THREAD " (since Linux 2.4.0-test8)"
1060 .BR CLONE_THREAD " (Linux 2.4.0-test8°Ê¹ß)"
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.
1069 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢»Ò¥×¥í¥»¥¹¤Ï¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ÈƱ¤¸¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Ë
1072 ¤Ë¤Ä¤¤¤Æ¤Î°Ê¹ß¤ÎµÄÏÀ¤òÆɤߤ䤹¤¯¤¹¤ë¤¿¤á¡¢
1073 ¡Ö¥¹¥ì¥Ã¥É¡×¤È¤¤¤¦ÍѸì¤Ï¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤ÎÃæ¤Î¥×¥í¥»¥¹¤ò
1074 »²¾È¤¹¤ë¤Î¤Ë»È¤¦¤³¤È¤È¤¹¤ë¡£
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
1082 .\"O return the TGID of the caller.
1083 ¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Ï¡¢ ¥¹¥ì¥Ã¥É½¸¹ç¤Ç°ì¤Ä¤Î PID ¤ò¶¦Í¤¹¤ë¤È¤¤¤¦ POSIX
1084 ¥¹¥ì¥Ã¥É¤Î³µÇ°¤ò¥µ¥Ý¡¼¥È¤¹¤ë¤¿¤á¤Ë Linux 2.4 ¤Ë²Ã¤¨¤é¤ì¤¿µ¡Ç½¤Ç¤¢¤Ã¤¿¡£
1085 ÆâÉôŪ¤Ë¤Ï¡¢¤³¤Î¶¦Í PID ¤Ï¤¤¤ï¤æ¤ë¤½¤Î¥¹¥ì¥Ã¥É¥°¥ë¡¼¥×¤Î
1086 ¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¼±ÊÌ»Ò (TGID) ¤Ç¤¢¤ë¡£
1087 Linux 2.4 °Ê¹ß¤Ç¤Ï¡¢
1089 ¤Î¸Æ¤Ó½Ð¤·¤Ç¤Ï¤½¤Î¥×¥í¥»¥¹¤Î¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥× ID ¤òÊÖ¤¹¡£
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
1096 .\"O and a thread can obtain
1097 .\"O its own TID using
1098 .\"O .BR gettid (2).
1099 ¤¢¤ë¥°¥ë¡¼¥×¤Ë°¤¹¤ë¥¹¥ì¥Ã¥É¤Ï (¥·¥¹¥Æ¥àÁ´ÂΤÇ) °ì°Õ¤Ê¥¹¥ì¥Ã¥É ID (TID)
1100 ¤Ç¶èÊ̤Ǥ¤ë¡£¿·¤·¤¤¥¹¥ì¥Ã¥É¤Î TID ¤Ï
1102 ¤Î¸Æ¤Ó½Ð¤·¸µ¤Ø´Ø¿ô¤Î·ë²Ì¤È¤·¤ÆÊÖ¤µ¤ì¡¢
1103 ¥¹¥ì¥Ã¥É¤Ï¼«Ê¬¼«¿È¤Î TID ¤ò
1107 .\"O When a call is made to
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
1115 .\"O of the new thread group.
1119 ¤Î¸Æ¤Ó½Ð¤·¤¬¹Ô¤ï¤ì¤ë¤È¡¢
1120 À¸À®¤µ¤ì¤¿¥¹¥ì¥Ã¥É¤Ï¤½¤Î¥¹¥ì¥Ã¥É¤Î TID ¤ÈƱ¤¸ÃͤΠTGID ¤ò»ý¤Ä
1121 ¿·¤·¤¤¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤ËÃÖ¤«¤ì¤ë¡£¤³¤Î¥¹¥ì¥Ã¥É¤Ï
1122 ¿·¤·¤¤¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Î¡Ö¥ê¡¼¥À¡¼¡×¤Ç¤¢¤ë¡£
1124 .\"O A new thread created with
1125 .\"O .B CLONE_THREAD
1126 .\"O has the same parent process as the caller of
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.
1134 ¤ò»ØÄꤷ¤ÆºîÀ®¤µ¤ì¤¿¿·¤·¤¤¥¹¥ì¥Ã¥É¤Ï¡¢
1138 ¤ò¸Æ¤Ó½Ð¤·¸µ¤ÈƱ¤¸¿Æ¥×¥í¥»¥¹¤ò»ý¤Ä¡£
1141 ¤ò¸Æ¤Ö¤È¡¢°ì¤Ä¤Î¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Ë°¤¹¥¹¥ì¥Ã¥É¤ÏÁ´¤ÆƱ¤¸ÃͤòÊÖ¤¹¡£
1143 .\"O .B CLONE_THREAD
1144 .\"O thread terminates, the thread that created it using
1148 .\"O (or other termination) signal;
1149 .\"O nor can the status of such a thread be obtained
1152 .\"O (The thread is said to be
1153 .\"O .IR detached .)
1155 ¤Çºî¤é¤ì¤¿¥¹¥ì¥Ã¥É¤¬½ªÎ»¤·¤¿ºÝ¤Ë¡¢
1158 ¤ò»È¤Ã¤ÆÀ¸À®¤·¤¿¥¹¥ì¥Ã¥É¤Ë¤Ï
1160 (¤â¤·¤¯¤Ï¾¤Î½ªÎ»¥·¥°¥Ê¥ë) ¤ÏÁ÷¿®¤µ¤ì¤Ê¤¤¡£
1163 ¤ò»È¤Ã¤Æ½ªÎ»¤·¤¿¥¹¥ì¥Ã¥É¤Î¾õÂÖ¤ò¼èÆÀ¤¹¤ë¤³¤È¤â¤Ç¤¤Ê¤¤
1164 (¤½¤Î¤è¤¦¤Ê¥¹¥ì¥Ã¥É¤Ï
1166 (ʬΥ¤µ¤ì¤¿) ¤È¤¤¤ï¤ì¤ë)¡£
1168 .\"O After all of the threads in a thread group terminate
1169 .\"O the parent process of the thread group is sent a
1171 .\"O (or other termination) signal.
1172 ¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Ë°¤¹Á´¤Æ¤Î¥¹¥ì¥Ã¥É¤¬½ªÎ»¤·¤¿¸å¡¢
1173 ¤½¤Î¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Î¿Æ¥×¥í¥»¥¹¤Ë
1175 (¤â¤·¤¯¤Ï¾¤Î½ªÎ»¥·¥°¥Ê¥ë) ¤¬Á÷¤é¤ì¤ë¡£
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 ¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Ë°¤¹¤¤¤º¤ì¤«¤Î¥¹¥ì¥Ã¥É¤¬
1183 ¤ò¼Â¹Ô¤¹¤ë¤È¡¢¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¡¦¥ê¡¼¥À¡¼°Ê³°¤ÎÁ´¤Æ¤Î¥¹¥ì¥Ã¥É¤Ï
1184 ½ªÎ»¤µ¤ì¡¢¿·¤·¤¤¥×¥í¥»¥¹¤¬¤½¤Î¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¡¦¥ê¡¼¥À¡¼¤Î²¼¤Ç
1187 .\"O If one of the threads in a thread group creates a child using
1189 .\"O then any thread in the group can
1191 .\"O for that child.
1192 ¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Ë°¤¹¥¹¥ì¥Ã¥É¤Î°ì¤Ä¤¬
1194 ¤ò»È¤Ã¤Æ»Ò¥×¥í¥»¥¹¤òºîÀ®¤·¤¿¾ì¹ç¡¢
1195 ¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Î¤É¤Î¥¹¥ì¥Ã¥É¤Ç¤¢¤Ã¤Æ¤â
1200 .\"O Since Linux 2.5.35,
1202 .\"O must also include
1203 .\"O .B CLONE_SIGHAND
1205 .\"O .B CLONE_THREAD
1207 Linux 2.5.35 °Ê¹ß¤Ç¤Ï¡¢
1213 ¤â´Þ¤Þ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
1215 .\"O Signals may be sent to a thread group as a whole (i.e., a TGID) using
1217 .\"O or to a specific thread (i.e., TID) using
1218 .\"O .BR tgkill (2).
1220 ¤ò»È¤Ã¤Æ¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×Á´ÂÎ (¤Ä¤Þ¤ê TGID) ¤Ë¥·¥°¥Ê¥ë¤òÁ÷¤ë¤³¤È¤â¤Ç¤¤ì¤Ð¡¢
1222 ¤ò»È¤Ã¤ÆÆÃÄê¤Î¥¹¥ì¥Ã¥É (¤Ä¤Þ¤ê TID) ¤Ë¥·¥°¥Ê¥ë¤òÁ÷¤ë¤³¤È¤â¤Ç¤¤ë¡£
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 (½ªÎ»¤·¤¿¤ê¡¢Ää»ß¤·¤¿¤ê¡¢Æ°ºî¤ò·Ñ³¤·¤¿¤ê¡¢Ìµ»ë¤µ¤ì¤¿¤ê¤¹¤ë)¡£
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),
1239 .\"O or for an individual thread, when sent with
1240 .\"O .BR tgkill (2).
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 ³Æ¡¹¤Î¥¹¥ì¥Ã¥É¤ÏÆȼ«¤Î¥·¥°¥Ê¥ë¥Þ¥¹¥¯¤ò»ý¤Ã¤Æ¤ª¤ê¡¢
1248 ¤À¤¬¡¢½èÍýÂÔ¤Á¤Î¥·¥°¥Ê¥ë¤Ë¤Ï¡¢
1250 ¤ÇÁ÷¿®¤µ¤ì¤ë¥×¥í¥»¥¹Á´ÂΤËÂФ¹¤ë¤â¤Î (¤Ä¤Þ¤ê¡¢¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Î
1251 ¤É¤Î¥á¥ó¥Ð¡¼¤Ë¤âÇÛÁ÷¤Ç¤¤ë¤â¤Î) ¤È¡¢
1253 ¤ÇÁ÷¿®¤µ¤ì¤ë¸Ä¡¹¤Î¥¹¥ì¥Ã¥É¤ËÂФ¹¤ë¤â¤Î¤¬¤¢¤ê¤¨¤ë¡£
1255 ¤ò¸Æ¤Ó½Ð¤¹¤È¡¢¥×¥í¥»¥¹Á´ÂΤËÂФ¹¤ë½èÍýÂÔ¤Á¥·¥°¥Ê¥ë¤È¸Æ¤Ó½Ð¤·¸µ¤Î
1256 ¥¹¥ì¥Ã¥É¤ËÂФ¹¤ë½èÍýÂÔ¤Á¥·¥°¥Ê¥ë¤ò·ë¹ç¤·¤¿¥·¥°¥Ê¥ë½¸¹ç¤¬ÊÖ¤µ¤ì¤ë¡£
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
1270 ¤ò»È¤Ã¤Æ¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Ë¥·¥°¥Ê¥ë¤¬Á÷¤é¤ì¤¿¾ì¹ç¤Ç¡¢
1271 ¤½¤Î¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤¬¤½¤Î¥·¥°¥Ê¥ë¤ËÂФ¹¤ë¥·¥°¥Ê¥ë¡¦¥Ï¥ó¥É¥é¤¬
1272 ÅÐÏ¿¤µ¤ì¤Æ¤¤¤¿¤È¤¤Ë¤Ï¡¢¥·¥°¥Ê¥ë¡¦¥Ï¥ó¥É¥é¤Ï¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Î
1273 ¥á¥ó¥Ð¡¼¤Î¤¦¤Á¡¢¤¿¤À°ì¤Ä¤Î¥¹¥ì¥Ã¥É¤Ç¤À¤±µ¯Æ°¤µ¤ì¤ë¡£¥Ï¥ó¥É¥é¤¬
1274 µ¯Æ°¤µ¤ì¤ë¥¹¥ì¥Ã¥É¤Ï¡¢¤½¤Î¥·¥°¥Ê¥ë¤ò¶Ø»ß (block) ¤·¤Æ¤¤¤Ê¤¤
1275 ¥á¥ó¥Ð¡¼¤ÎÃ椫¤é°ì¤Ä¤À¤±¤¬¾¡¼ê¤Ë (arbitrarily) Áª¤Ð¤ì¤ë¡£
1276 ¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Ë°¤¹Ê£¿ô¤Î¥¹¥ì¥Ã¥É¤¬
1278 ¤ò»È¤Ã¤ÆƱ¤¸¥·¥°¥Ê¥ë¤òÂԤäƤ¤¤ë¾ì¹ç¡¢
1279 ¤³¤ì¤é¤Î¥¹¥ì¥Ã¥É¤ÎÃ椫¤é°ì¤Ä¤ò¥«¡¼¥Í¥ë¤¬¾¡¼ê¤ËÁªÂò¤·¡¢
1282 ¤ò»È¤Ã¤ÆÁ÷¿®¤µ¤ì¤¿¥·¥°¥Ê¥ë¤ò¼õ¿®¤¹¤ë¡£
1284 .\"O .BR CLONE_UNTRACED " (since Linux 2.5.46)"
1285 .BR CLONE_UNTRACED " (Linux 2.5.46 °Ê¹ß)"
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.
1292 ¤¬»ØÄꤵ¤ì¤ë¤È¡¢ trace ¤ò¹Ô¤Ã¤Æ¤¤¤ë¥×¥í¥»¥¹¤Ï
1295 ¤òŬÍѤ¹¤ë¤³¤È¤¬¤Ç¤¤Ê¤¤¡£
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
1307 .\"O .BR vfork (2)).
1311 ¤ÈƱÍͤË) »Ò¥×¥í¥»¥¹¤¬
1315 ¤Ë¤è¤Ã¤Æ²¾ÁÛ¥á¥â¥ê¤ò²òÊü¤¹¤ë¤Þ¤Ç¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î¼Â¹Ô¤ÏÄä»ß¤µ¤ì¤ë¡£
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.
1323 ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢
1325 ¸Æ¤Ó½Ð¤·¸å¤Ï¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤È»Ò¥×¥í¥»¥¹¤Î
1326 ξÊý¤¬¥¹¥±¥¸¥å¡¼¥ëÂоݤȤʤꡢ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï¤³¤ì¤é¤Î¥×¥í¥»¥¹¤Î
1327 ¼Â¹Ô½ç½ø¤Ë°Í¸¤·¤Ê¤¤¤è¤¦¤Ë¤¹¤Ù¤¤Ç¤¢¤ë¡£
1332 .\"O is set, the calling process and the child process run in the same memory
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
1340 .\"O by the child or calling process also affects the other process.
1342 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤È»Ò¥×¥í¥»¥¹¤ÏƱ¤¸¥á¥â¥ê¶õ´Ö¤Ç
1343 ¼Â¹Ô¤µ¤ì¤ë¡£Æäˡ¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ä»Ò¥×¥í¥»¥¹¤Î°ìÊý¤¬¥á¥â¥ê¤Ë
1344 ½ñ¤¹þ¤ó¤ÀÆâÍƤϤ⤦°ìÊý¤Î¥×¥í¥»¥¹¤«¤é¤â¸«¤ë¤³¤È¤¬¤Ç¤¤ë¡£¤µ¤é¤Ë¡¢
1345 »Ò¥×¥í¥»¥¹¤ä¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î°ìÊý¤¬
1349 ¤ò»È¤Ã¤Æ¥á¥â¥ê¤ò¥Þ¥Ã¥×¤·¤¿¤ê¥¢¥ó¥Þ¥Ã¥×¤·¤¿¾ì¹ç¡¢
1350 ¤â¤¦°ìÊý¤Î¥×¥í¥»¥¹¤Ë¤â±Æ¶Á¤¬µÚ¤Ö¡£
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
1357 .\"O Memory writes or file mappings/unmappings performed by one of the
1358 .\"O processes do not affect the other, as with
1361 ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢»Ò¥×¥í¥»¥¹¤Ï
1363 ¤¬¼Â¹Ô¤µ¤ì¤¿»þÅÀ¤Ç¤Î¡¢¿Æ¥×¥í¥»¥¹¤Î¥á¥â¥ê¶õ´Ö¤ò¥³¥Ô¡¼¤·¤¿
1364 Ê̤Υá¥â¥ê¶õ´Ö¤Ç¼Â¹Ô¤µ¤ì¤ë¡£
1365 °ìÊý¤Î¥×¥í¥»¥¹¤¬¹Ô¤Ã¤¿¥á¥â¥ê¤Ø¤Î½ñ¤¹þ¤ß¤ä
1366 ¥Õ¥¡¥¤¥ë¤Î¥Þ¥Ã¥×/¥¢¥ó¥Þ¥Ã¥×¤Ï¡¢
1368 ¤Î¾ì¹ç¤ÈƱÍÍ¡¢¤â¤¦°ìÊý¤Î¥×¥í¥»¥¹¤Ë¤Ï±Æ¶Á¤·¤Ê¤¤¡£
1372 .\"O system call corresponds more closely to
1374 .\"O in that execution in the child continues from the point of the
1378 .\"O only requires the
1382 .\"O arguments, which have the same meaning as for
1384 .\"O (Note that the order of these arguments differs from
1387 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï¡¢¤è¤ê
1389 ¤Ë¶á¤¤¤«¤¿¤Á¤Ë¤Ê¤Ã¤Æ¤ª¤ê¡¢»Ò¥×¥í¥»¥¹¤Î¼Â¹Ô¤¬¸Æ¤Ó½Ð¤·¤¬¹Ô¤ï¤ì¤¿¾ì½ê¤«¤é
1393 ¤¬É¬ÍפȤ¹¤ë°ú¤¿ô¤Ï
1397 ¤À¤±¤Ç¤¢¤ê¡¢¤½¤ì¤é¤Ï
1400 (¤³¤ì¤é¤Î°ú¤¿ô¤Î½çÈÖ¤Ï
1402 ¤È¤Ï°Û¤Ê¤ë¤³¤È¤ËÃí°Õ¤»¤è)¡£
1404 .\"O Another difference for
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
1411 .\"O In this case, for correct operation, the
1413 .\"O option should not be specified.
1415 ¤Î¤â¤¦°ì¤Ä¤Î°ã¤¤¤Ï¡¢
1417 °ú¤¿ô¤¬¥¼¥í¤Ç¤âÎɤ¤¤³¤È¤Ç¤¢¤ë¡£¤³¤Î¾ì¹ç¤Ë¤Ï¡¢¤É¤Á¤é¤«¤Î¥×¥í¥»¥¹¤¬
1418 ¥¹¥¿¥Ã¥¯¤òÊѹ¹¤·¤¿»þ¤Ë¡¢½ñ¤¹þ¤ß»þ¥³¥Ô¡¼ (copy-on-write) Êý¼°¤Ë¤è¤ê
1419 »Ò¥×¥í¥»¥¹¤¬¥¹¥¿¥Ã¥¯¡¦¥Ú¡¼¥¸¤ÎÆÈΩ¤·¤¿¥³¥Ô¡¼¤òÆÀ¤é¤ì¤ë¤³¤È¤¬Êݾڤµ¤ì¤ë¡£
1420 ¤³¤Î¾ì¹ç¡¢Àµ¾ï¤ËÆ°ºî¤µ¤»¤ë¤¿¤á¤Ë¤Ï¡¢
1422 ¥ª¥×¥·¥ç¥ó¤ò»ØÄꤷ¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
1424 .\"O In Linux 2.4 and earlier,
1426 .\"O does not take arguments
1431 Linux 2.4 °ÊÁ°¤Ç¤Ï¡¢
1438 .\"O .SH "RETURN VALUE"
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
1447 .\"O will be set appropriately.
1448 .\" gettid(2) ¤Ï current->pid ¤òÊÖ¤¹
1449 .\" getpid(2) ¤Ï current->tgid ¤òÊÖ¤¹
1450 À®¸ù¤·¤¿¾ì¹ç¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¼Â¹Ô¥¹¥ì¥Ã¥É¤Ë¤Ï»Ò¥×¥í¥»¥¹¤Î¥¹¥ì¥Ã¥ÉID ¤¬ÊÖ¤µ¤ì¤ë¡£
1451 ¼ºÇÔ¤·¤¿¾ì¹ç¡¢ ¸Æ¤Ó½Ð¤·¸µ¤Î¥³¥ó¥Æ¥¥¹¥È¤Ë¤Ï \-1 ¤¬ÊÖ¤µ¤ì¡¢»Ò¥×¥í¥»¥¹¤Ï
1454 ¤¬Å¬ÀÚ¤ËÀßÄꤵ¤ì¤ë¡£
1459 .\"O Too many processes are already running.
1460 ¤¹¤Ç¤Ë¼Â¹ÔÃæ¤Î¥×¥í¥»¥¹¤¬Â¿¤¹¤®¤ë¡£
1463 .\"O .B CLONE_SIGHAND
1464 .\"O was specified, but
1467 .\"O (Since Linux 2.6.0-test6.)
1469 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤¿¤¬¡¢
1471 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤«¤Ã¤¿¡£
1472 (Linux 2.6.0-test6 °Ê¹ß)
1475 .\"O .B CLONE_THREAD
1476 .\"O was specified, but
1477 .\"O .B CLONE_SIGHAND
1479 .\"O (Since Linux 2.5.35.)
1481 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤¿¤¬¡¢
1483 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤«¤Ã¤¿¡£
1487 .\"O .\" Precisely one of
1488 .\"O .\" .B CLONE_DETACHED
1490 .\"O .\" .B CLONE_THREAD
1491 .\"O .\" was specified.
1492 .\"O .\" (Since Linux 2.6.0-test6.)
1493 .\" .B CLONE_DETACHED
1496 .\" ¤Î¤¤¤º¤ì¤«°ìÊý¤À¤±¤¬»ØÄꤵ¤ì¤¿¡£
1497 .\" (Linux 2.6.0-test6 °Ê¹ß)
1504 .\"O were specified in
1515 .\"O .B CLONE_NEWIPC
1517 .\"O .B CLONE_SYSVSEM
1518 .\"O were specified in
1529 .\"O .BR CLONE_NEWPID
1531 .\"O .BR CLONE_THREAD
1532 .\"O were specified in
1544 .\"O when a zero value is specified for
1545 .\"O .IR child_stack .
1547 ¤Ë¥¼¥í¤ò»ØÄꤷ¤¿¾ì¹ç¤Ë
1552 .\"O .BR CLONE_NEWIPC
1553 .\"O was specified in
1555 .\"O but the kernel was not configured with the
1556 .\"O .B CONFIG_SYSVIPC
1558 .\"O .BR CONFIG_IPC_NS
1563 ¤¬»ØÄꤵ¤ì¤¿¤¬¡¢¥«¡¼¥Í¥ë¤Ç¥ª¥×¥·¥ç¥ó
1567 ¤¬Í¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤Ê¤«¤Ã¤¿¡£
1570 .\"O .BR CLONE_NEWNET
1571 .\"O was specified in
1573 .\"O but the kernel was not configured with the
1574 .\"O .B CONFIG_NET_NS
1579 ¤¬»ØÄꤵ¤ì¤¿¤¬¡¢¥«¡¼¥Í¥ë¤Ç¥ª¥×¥·¥ç¥ó
1581 ¤¬Í¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤Ê¤«¤Ã¤¿¡£
1584 .\"O .BR CLONE_NEWPID
1585 .\"O was specified in
1587 .\"O but the kernel was not configured with the
1588 .\"O .B CONFIG_PID_NS
1593 ¤¬»ØÄꤵ¤ì¤¿¤¬¡¢¥«¡¼¥Í¥ë¤Ç¥ª¥×¥·¥ç¥ó
1595 ¤¬Í¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤Ê¤«¤Ã¤¿¡£
1598 .\"O .BR CLONE_NEWUTS
1599 .\"O was specified in
1601 .\"O but the kernel was not configured with the
1607 ¤¬»ØÄꤵ¤ì¤¿¤¬¡¢¥«¡¼¥Í¥ë¤Ç¥ª¥×¥·¥ç¥ó
1609 ¤¬Í¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤Ê¤«¤Ã¤¿¡£
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
1615 »Ò¥×¥í¥»¥¹¤Î¤¿¤á¤Ë³ÎÊݤ¹¤Ù¤¥¿¥¹¥¯¹½Â¤ÂΤ䡢¸Æ¤Ó½Ð¤·¸µ¤Î¥³¥ó¥Æ¥¥¹¥È¤Î
1616 °ìÉô¤ò¥³¥Ô¡¼¤¹¤ë¤Î¤ËɬÍפʥá¥â¥ê¤ò½½Ê¬¤Ë³ä¤êÅö¤Æ¤ë¤³¤È¤¬¤Ç¤¤Ê¤¤¡£
1619 .\"O .BR CLONE_NEWIPC ,
1620 .\"O .BR CLONE_NEWNET ,
1621 .\"O .BR CLONE_NEWNS ,
1622 .\"O .BR CLONE_NEWPID ,
1624 .\"O .BR CLONE_NEWUTS
1625 .\"O was specified by an unprivileged process (process without \fBCAP_SYS_ADMIN\fP).
1626 ÈóÆø¢¥×¥í¥»¥¹ (\fBCAP_SYS_ADMIN\fP ¤ò»ý¤¿¤Ê¤¤¥×¥í¥»¥¹) ¤¬
1636 .\"O was specified by a process other than process 0.
1637 PID ¤¬ 0 °Ê³°¤Î¥×¥í¥»¥¹¤Ë¤è¤Ã¤Æ
1642 .\"O There is no entry for
1645 .\"O glibc2 provides
1647 .\"O as described in this manual page.
1652 ¤¬Ä󶡤µ¤ì¤Æ¤ª¤ê¡¢¤³¤Î¥Þ¥Ë¥å¥¢¥ë¥Ú¡¼¥¸¤ËµºÜ¤ÎÄ̤ê¤Ç¤¢¤ë¡£
1653 .\"O .SH "CONFORMING TO"
1659 .\"O calls are Linux-specific and should not be used in programs
1660 .\"O intended to be portable.
1664 ¥³¡¼¥ë¤Ï Linux ÆÃͤǤ¢¤ê¡¢°Ü¿¢¤ò¹Íθ¤·¤¿¥×¥í¥°¥é¥à¤Ç¤Ï»ÈÍѤ¹¤Ù¤
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 ·ÏÎó¤Ç¤Ï¡¢°ìÈÌŪ¤Ë¤Ï
1679 ¥Õ¥é¥°¤ò»ØÄꤷ¤Æ¤â¿·¤·¤¤¥¹¥ì¥Ã¥É¤Î¿Æ¤ò
1680 ¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Î¿Æ¤ÈƱ¤¸¤Ë¤Ï¤·¤Ê¤¤¡£
1681 ¤·¤«¤·¡¢¥Ð¡¼¥¸¥ç¥ó 2.4.7¡Á2.4.18 ¤Î¥«¡¼¥Í¥ë¤Ç¤Ï¡¢
1682 (¥«¡¼¥Í¥ë 2.6 ¤ÈƱ¤¸¤è¤¦¤Ë) CLONE_THREAD ¥Õ¥é¥°¤ò»ØÄꤹ¤ë¤È¡¢
1683 °ÅÌۤΤ¦¤Á¤Ë CLONE_PARENT ¥Õ¥é¥°¤ò»ØÄꤷ¤¿¤³¤È¤Ë¤Ê¤ë¡£
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
1691 .\"O .B CLONE_THREAD
1693 .\"O This flag is still defined, but has no effect.
1695 ¤È¤¤¤¦¥Õ¥é¥°¤¬¡¢2.5.32 ¤ÇƳÆþ¤µ¤ì¤Æ°ÊÍ褷¤Ð¤é¤¯¤Î´Ö¸ºß¤·¤¿¡£
1696 ¤³¤Î¥Õ¥é¥°¤Ï¿Æ¥×¥í¥»¥¹¤¬»Ò¥×¥í¥»¥¹½ªÎ»¤Î¥·¥°¥Ê¥ë¤òɬÍפȤ·¤Ê¤¤¤³¤È¤ò
1698 2.6.2 ¤Ç¡¢ CLONE_DETATCHED ¤ò CLONE_THREAD ¤È°ì½ï¤Ë»ØÄꤹ¤ëɬÍפϤʤ¯¤Ê¤Ã¤¿¡£
1699 ¤³¤Î¥Õ¥é¥°¤Ï¤Þ¤ÀÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤¬¡¢²¿¤Î¸ú²Ì¤â¤Ê¤¤¡£
1703 .\"O should not be called through vsyscall, but directly through
1704 .\"O .IR "int $0x80" .
1707 ¤Ï vsyscall ·Ðͳ¤Ç¤Ï¤Ê¤¯¡¢Ä¾ÀÜ
1709 ·Ðͳ¤Ç¸Æ¤Ó½Ð¤¹¤Ù¤¤Ç¤¢¤ë¡£
1711 .\"O On ia64, a different system call is used:
1712 ia64 ¤Ç¤Ï¡¢Ê̤Υ·¥¹¥Æ¥à¥³¡¼¥ë¤¬»ÈÍѤµ¤ì¤ë:
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 " */ );"
1723 .\"O .BR __clone2 ()
1724 .\"O system call operates in the same way as
1727 .\"O .I child_stack_base
1728 .\"O points to the lowest address of the child's stack area,
1731 .\"O specifies the size of the stack pointed to by
1732 .\"O .IR child_stack_base .
1736 ¤ÈƱ¤¸¤è¤¦¤ËÆ°ºî¤¹¤ë¤¬¡¢°Ê²¼¤ÎÅÀ¤¬°Û¤Ê¤ë:
1738 ¤Ï»Ò¥×¥í¥»¥¹¤Î¥¹¥¿¥Ã¥¯¥¨¥ê¥¢¤ÎºÇ¾®¤Î¥¢¥É¥ì¥¹¤ò»Ø¤·¡¢
1742 ¤¬»Ø¤·¼¨¤¹¥¹¥¿¥Ã¥¯¥¨¥ê¥¢¤ÎÂ礤µ¤ò¼¨¤¹¡£
1745 .\"O Versions of the GNU C library that include the NPTL threading library
1746 .\"O contain a wrapper function for
1748 .\"O that performs caching of PIDs.
1749 NPTL ¥¹¥ì¥Ã¥É¡¦¥é¥¤¥Ö¥é¥ê¤ò´Þ¤ó¤Ç¤¤¤ë GNU C ¥é¥¤¥Ö¥é¥ê¤Î¤¤¤¯¤Ä¤«¤Î¥Ð¡¼¥¸¥ç¥ó
1752 ¤Î¥é¥Ã¥Ñ¡¼´Ø¿ô¤¬´Þ¤Þ¤ì¤Æ¤ª¤ê¡¢¤³¤Î¥é¥Ã¥Ñ¡¼´Ø¿ô¤Ï PID ¤ò¥¥ã¥Ã¥·¥å¤¹¤ë¡£
1753 .\"O This caching relies on support in the glibc wrapper for
1755 .\"O but as currently implemented,
1756 .\"O the cache may not be up to date in some circumstances.
1757 ¤³¤Î¥¥ã¥Ã¥·¥å½èÍý¤¬Àµ¤·¤¯Æ°ºî¤¹¤ë¤¿¤á¤Ë¤Ï glibc ¤Î
1759 ¤Î¥é¥Ã¥Ñ¡¼´Ø¿ô¤Ç¤Î½õ¤±¤¬É¬ÍפÀ¤¬¡¢¸½¾õ¤Î¼ÂÁõ¤Ç¤Ï¡¢
1760 ¤¢¤ë¾õ¶·²¼¤Ë¤ª¤¤¤Æ¥¥ã¥Ã¥·¥å¤¬ºÇ¿·¤È¤Ê¤é¤Ê¤¤²ÄǽÀ¤¬¤¢¤ë¡£
1762 .\"O if a signal is delivered to the child immediately after the
1764 .\"O call, then a call to
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.
1772 ¤Î¸Æ¤Ó½Ð¤·Ä¾¸å¤Ë¥·¥°¥Ê¥ë¤¬»Ò¥×¥í¥»¥¹¤ËÇÛÁ÷¤µ¤ì¤¿¾ì¹ç¤Ë¡¢
1773 ¤½¤Î¥·¥°¥Ê¥ë¤ËÂФ¹¤ë¥Ï¥ó¥É¥éÆâ¤Ç
1775 ¤ò¸Æ¤Ó½Ð¤¹¤È¡¢¤½¤ì¤Þ¤Ç¤Ë clone ¤Î¥é¥Ã¥Ñ¡¼´Ø¿ô¤¬»Ò¥×¥í¥»¥¹¤Î PID ¥¥ã¥Ã¥·¥å¤ò
1776 ¹¹¿·¤¹¤ëµ¡²ñ¤¬ÆÀ¤é¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹ ("¿Æ¥×¥í¥»¥¹") ¤Î PID ¤¬
1777 ÊÖ¤µ¤ì¤ë²ÄǽÀ¤¬¤¢¤ë¡£
1778 .\"O (This discussion ignores the case where the child was created using
1779 .\"O .BR CLONE_THREAD ,
1783 .\"O return the same value in the child and in the process that called
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
1788 .\"O argument includes
1789 .\"O .BR CLONE_VM .)
1790 (¤³¤ÎµÄÏÀ¤Ç¤Ï¡¢»Ò¥×¥í¥»¥¹¤¬
1792 ¤ò»È¤Ã¤ÆºîÀ®¤µ¤ì¤¿¾ì¹ç¤Î¤³¤È¤Ï̵»ë¤·¤Æ¤¤¤ë¡£
1795 ¤òºî¤Ã¤ÆºîÀ®¤µ¤ì¤¿¾ì¹ç¤Ë¤Ï¡¢
1796 ¸Æ¤Ó½Ð¤·¸µ¤È»Ò¥×¥í¥»¥¹¤ÏƱ¤¸¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Ë°¤¹¤Î¤Ç¡¢
1800 ¤ò¸Æ¤Ó½Ð¤·¤¿¥×¥í¥»¥¹¤ÇƱ¤¸ÃͤòÊÖ¤¹¤Î¤¬¡ÖÀµ¤·¤¤¡×¡£
1801 ¥¥ã¥Ã¥·¥å¤¬ºÇ¿·¤È¤Ê¤é¤Ê¤¤ÌäÂê (stale-cache problem) ¤Ï¡¢
1805 ¤¬´Þ¤Þ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤âȯÀ¸¤·¤Ê¤¤¡£)
1806 .\"O To get the truth, it may be necessary to use code such as the following:
1807 ËÜÅö¤ÎÃͤòÆÀ¤ë¤¿¤á¤Ë¤Ï¡¢¼¡¤Î¤è¤¦¤Ê¥³¡¼¥É¤ò»È¤¦É¬Íפ¬¤¢¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
1810 #include <syscall.h>
1814 mypid = syscall(SYS_getpid);
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
1825 .BR set_thread_area (2),
1826 .BR set_tid_address (2),
1830 .BR capabilities (7),