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-09-10 "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 is not yet complete,
517 .\"O but probably will be mostly complete by about Linux 2.6.28.)
518 (¤³¤Î¥Õ¥é¥°¤Î¼ÂÁõ¤Ï¤Þ¤À´°Î»¤·¤Æ¤¤¤Ê¤¤¤¬¡¢
519 ¤ª¤½¤é¤¯ Linux 2.6.28 ¤¢¤¿¤ê¤Þ¤Ç¤Ë¤Ï¤Û¤Ü´°À®¤¹¤ë¤³¤È¤À¤í¤¦¡£)
523 .\"O is set, then create the process in a new network namespace.
524 .\"O If this flag is not set, then (as with
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.
530 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢¿·¤·¤¤¥Í¥Ã¥È¥ï¡¼¥¯Ì¾Á°¶õ´Ö (network namaspace)
531 ¤Ç¥×¥í¥»¥¹¤òºîÀ®¤¹¤ë¡£
532 ¤³¤Î¥Õ¥é¥°¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢
534 ¤Î¾ì¹ç¤ÈƱÍÍ) ¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ÈƱ¤¸¥Í¥Ã¥È¥ï¡¼¥¯Ì¾Á°¶õ´Ö¤Ç¥×¥í¥»¥¹¤¬
536 ¤³¤Î¥Õ¥é¥°¤Ï¡¢¥³¥ó¥Æ¥Ê¤Î¼ÂÁõ¤Ç¤Î»ÈÍѤò°Õ¿Þ¤·¤ÆÍÑ°Õ¤µ¤ì¤¿¤â¤Î¤Ç¤¢¤ë¡£
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
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 ¥×¥í¥È¥³¥ë¥¹¥¿¥Ã¥¯¡¢
556 ¥Ç¥£¥ì¥¯¥È¥ê¥Ä¥ê¡¼¡¢¥½¥±¥Ã¥È¤Ê¤É¤Ç¤¢¤ë)¡£
557 ʪÍý¥Í¥Ã¥È¥ï¡¼¥¯¥Ç¥Ð¥¤¥¹¤¬½ê°¤Ç¤¤ë¥Í¥Ã¥È¥ï¡¼¥¯Ì¾Á°¶õ´Ö¤Ï°ì¤Ä¤À¤±¤Ç¤¢¤ë¡£
558 ²¾Áۥͥåȥ¥¯¥Ç¥Ð¥¤¥¹ ("veth") ¤Î¥Ú¥¢¤Ë¤è¤ê
559 ¥Ñ¥¤¥×É÷¤ÎÃê¾Ý²½ (abstraction) ¤¬¼Â¸½¤µ¤ì¤Æ¤ª¤ê¡¢
560 ¤³¤ì¤ò»È¤¦¤³¤È¤Ç¡¢¥Í¥Ã¥È¥ï¡¼¥¯Ì¾Á°¶õ´Ö´Ö¤Î¥È¥ó¥Í¥ë¤òºîÀ®¤·¤¿¤ê¡¢
561 Ê̤Î̾Á°¶õ´Ö¤ÎʪÍý¥Í¥Ã¥È¥ï¡¼¥¯¥Ç¥Ð¥¤¥¹¤Ø¤Î¥Ö¥ê¥Ã¥¸¤òºîÀ®¤·¤¿¤ê
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 (¿Æ¥×¥í¥»¥¹¤Î¥Í¥Ã¥È¥ï¡¼¥¯Ì¾Á°¶õ´Ö¤ËÌᤵ¤ì¤ëÌõ¤Ç¤Ï¤Ê¤¤)¡£
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 ¤³¤Î¥Õ¥é¥°¤ò»ÈÍѤ¹¤ë¤¿¤á¤Ë¤Ï¡¢
581 ¤ò͸ú¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤³¤È¡¢
583 .RB ( CAP_SYS_ADMIN )
584 ¤ò»ý¤Ã¤Æ¤¤¤ë¤³¤È¤¬É¬ÍפǤ¢¤ë¡£
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) ¤Ç³«»Ï¤¹¤ë¡£
591 .\"O Every process lives in a mount namespace.
594 .\"O of a process is the data (the set of mounts) describing the file hierarchy
595 .\"O as seen by that process.
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 ¤Î½¸¹ç) ¤Ç¤¢¤ë¡£
608 ¥Õ¥é¥°¤¬¥»¥Ã¥È¤µ¤ì¤º¤Ë
612 ¤¬¸Æ¤Ð¤ì¤ë¤È¡¢»Ò¥×¥í¥»¥¹¤Ï¿Æ¥×¥í¥»¥¹¤ÈƱ¤¸¥Þ¥¦¥ó¥È̾Á°¶õ´Ö¤ËºîÀ®¤µ¤ì¤ë¡£
613 .\"O The system calls
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.
623 ¤¬¸Æ¤Ð¤ì¤ë¤È¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î¥Þ¥¦¥ó¥È̾Á°¶õ´Ö¤¬Êѹ¹¤µ¤ì¡¢¤³¤Î·ë²Ì
624 ¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ÈƱ¤¸Ì¾Á°¶õ´Ö¤Ë¤¤¤ë¥×¥í¥»¥¹¤Ï¤¹¤Ù¤Æ±Æ¶Á¤ò¼õ¤±¤ë¤¬¡¢
625 °Û¤Ê¤ë¥Þ¥¦¥ó¥È̾Á°¶õ´Ö¤Ë¤¤¤ë¥×¥í¥»¥¹¤Ï±Æ¶Á¤ò¼õ¤±¤Ê¤¤¡£
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.
636 ¤¬¸Æ¤Ð¤ì¤ë¤È¡¢clone ¤ÇºîÀ®¤µ¤ì¤¿»Ò¥×¥í¥»¥¹¤Ï¿·¤·¤¤¥Þ¥¦¥ó¥È̾Á°¶õ´Ö¤Ç
637 ³«»Ï¤µ¤ì¤ë¡£¿·¤·¤¤Ì¾Á°¶õ´Ö¤Ï¿Æ¥×¥í¥»¥¹¤Î̾Á°¶õ´Ö¤Î¥³¥Ô¡¼¤Ç½é´ü²½¤µ¤ì¤ë¡£
639 .\"O Only a privileged process (one having the \fBCAP_SYS_ADMIN\fP capability)
643 .\"O It is not permitted to specify both
650 Æø¢¥×¥í¥»¥¹ (\fBCAP_SYS_ADMIN\fP ¥±¡¼¥Ñ¥Ó¥ê¥Æ¥£¤ò»ý¤Ä¥×¥í¥»¥¹) ¤Î¤ß¤¬
652 ¥Õ¥é¥°¤ò»ØÄꤹ¤ë¤³¤È¤¬¤Ç¤¤ë¡£
659 ¤ÎξÊý¤ò»ØÄꤹ¤ë¤³¤È¤Ï¤Ç¤¤Ê¤¤¡£
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>
668 .\" The primary kernel commit is 30e49c263e36341b60b735cbef5ca37912549264
669 .\" Author: Pavel Emelyanov <xemul@openvz.org>
672 .\"O is set, then create the process in a new PID namespace.
673 .\"O If this flag is not set, then (as with
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.
679 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢¿·¤·¤¤ PID ̾Á°¶õ´Ö¤Ç¥×¥í¥»¥¹¤òºîÀ®¤¹¤ë¡£
680 ¤³¤Î¥Õ¥é¥°¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢
682 ¤Î¾ì¹ç¤ÈƱÍÍ) ¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ÈƱ¤¸ PID ̾Á°¶õ´Ö¤Ç
683 ¥×¥í¥»¥¹¤¬ºîÀ®¤µ¤ì¤ë¡£
684 ¤³¤Î¥Õ¥é¥°¤Ï¡¢¥³¥ó¥Æ¥Ê¤Î¼ÂÁõ¤Ç¤Î»ÈÍѤò°Õ¿Þ¤·¤ÆÍÑ°Õ¤µ¤ì¤¿¤â¤Î¤Ç¤¢¤ë¡£
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
693 .\"O will produce processes with PIDs that are unique within the namespace.
694 PID ̾Á°¶õ´Ö¤Ï¡¢PID ¤Ë´Ø¤·¤ÆʬΥ¤µ¤ì¤¿´Ä¶¤òÄ󶡤¹¤ë¤â¤Î¤Ç¤¢¤ë¡£
695 ¿·¤·¤¤Ì¾Á°¶õ´Ö¤Ë¤ª¤±¤ë PID ¤Ï 1 ¤«¤é»Ï¤Þ¤ê
696 (¤³¤ì¤Ï¥¹¥¿¥ó¥É¥¢¥í¥ó¤Î¥·¥¹¥Æ¥à¤È»÷¤¿¤è¤¦¤Ê´¶¤¸)¡¢
700 ¤ò¸Æ¤Ó½Ð¤¹¤È¡¢¤½¤Î̾Á°¶õ´Ö¤Ç°ì°Õ¤Ê PID ¤ò»ý¤Ã¤¿¥×¥í¥»¥¹¤¬ºîÀ®¤µ¤ì¤ë¡£
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
709 .\"O Unlike the traditional
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 ¿·¤·¤¤Ì¾Á°¶õ´Ö¤ÇºîÀ®¤µ¤ì¤ëºÇ½é¤Î¥×¥í¥»¥¹
716 ¥Õ¥é¥°¤ò»È¤Ã¤ÆºîÀ®¤µ¤ì¤¿¥×¥í¥»¥¹) ¤Î PID ¤Ï 1 ¤Ç¤¢¤ê¡¢
717 ¤³¤Î¥×¥í¥»¥¹¤Ï¤½¤Î̾Á°¶õ´Ö¤Ë¤ª¤±¤ë "init" ¥×¥í¥»¥¹¤È¤Ê¤ë¡£
718 ¤³¤Î̾Á°¶õ´Ö¤Ë¤ª¤¤¤Æ¸É»ù (orphaned) ¤È¤Ê¤Ã¤¿»Ò¥×¥í¥»¥¹¤Ë¤Ä¤¤¤Æ¤Ï¡¢
720 ¤Ç¤Ï¤Ê¤¯¤³¤Î¥×¥í¥»¥¹¤¬¿Æ¥×¥í¥»¥¹¤È¤Ê¤ë¡£
723 ¥×¥í¥»¥¹¤È¤Ï°ã¤¤¡¢PID ̾Á°¶õ´Ö¤Î "init" ¥×¥í¥»¥¹¤Ï½ªÎ» (terminated) ¤¹¤ë
724 ¤³¤È¤¬¤Ç¤¡¢¤½¤Î¾ì¹ç¤Ë¤Ï¡¢¤³¤Î̾Á°¶õ´Ö¤ÎÁ´¤Æ¤Î¥×¥í¥»¥¹¤¬½ªÎ»¤µ¤ì¤ë¡£
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.
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 ¤ÏÂбþ¤¹¤ë̾Á°¶õ´Ö¤Ë¤ª¤¤¤Æ°ì°Õ¤Ç¤¢¤ë¡£
757 ¤ò¸Æ¤Ó½Ð¤¹¤È¡¢¾ï¤Ë¤½¤Î¥×¥í¥»¥¹¤¬Â¸ºß¤·¤Æ¤¤¤ë̾Á°¶õ´Ö¤Ë¤ª¤±¤ë
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
764 .\"O so that tools such as
767 ¿·¤·¤¤Ì¾Á°¶õ´Ö¤ÎºîÀ®¸å¤Ë¤Ï¡¢
770 ¤È¤¤¤Ã¤¿¥Ä¡¼¥ë¤¬Àµ¤·¤¯Æ°ºî¤¹¤ë¤è¤¦¤Ë¡¢
771 ¼«¿È¤Î root ¥Ç¥£¥ì¥¯¥È¥ê¤òÊѹ¹¤·¡¢
773 ¤Ë¿·¤·¤¤ procfs ¥¤¥ó¥¹¥¿¥ó¥¹¤ò¥Þ¥¦¥ó¥È¤¹¤ë¤Î¤¬¤è¤¤¤À¤í¤¦¡£
774 .\" mount -t proc proc /proc
777 .\"O is also included in
779 .\"O then it isn't necessary to change the root directory:
780 .\"O a new procfs instance can be mounted directly over
785 ¤â»ØÄꤵ¤ì¤Æ¤¤¤¿¾ì¹ç¤Ë¤Ï¡¢root ¥Ç¥£¥ì¥¯¥È¥ê¤òÊѹ¹¤¹¤ëɬÍפϤʤ¯¡¢
786 ¤¤¤¤Ê¤ê¿·¤·¤¤ procfs ¥¤¥ó¥¹¥¿¥ó¥¹¤ò
788 ¤Ë¥Þ¥¦¥ó¥È¤¹¤ë¤³¤È¤¬¤Ç¤¤ë¡£)
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 ¤³¤Î¥Õ¥é¥°¤ò»ÈÍѤ¹¤ë¤¿¤á¤Ë¤Ï¡¢
799 ¤ò͸ú¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤³¤È¡¢
801 .RB ( CAP_SYS_ADMIN )
802 ¤ò»ý¤Ã¤Æ¤¤¤ë¤³¤È¤¬É¬ÍפǤ¢¤ë¡£
805 ¤ÈÁȤ߹ç¤ï¤»¤Æ»È¤¦¤³¤È¤Ï¤Ç¤¤Ê¤¤¡£
807 .\"O .BR CLONE_NEWUTS " (since Linux 2.6.19)"
808 .BR CLONE_NEWUTS " (Linux 2.6.19 °Ê¹ß)"
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
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.
820 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢¿·¤·¤¤ UTS ̾Á°¶õ´Ö¤Ç¥×¥í¥»¥¹¤òºîÀ®¤¹¤ë¡£
821 ¿·¤·¤¤ UTS ̾Á°¶õ´Ö¤Î¼±Ê̻Ҥνé´üÃͤϡ¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î
822 UTS ̾Á°¶õ´Ö¤Î¼±Ê̻ҤòÊ£À½¤·¤¿¤â¤Î¤È¤Ê¤ë¡£
823 ¤³¤Î¥Õ¥é¥°¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢
825 ¤Î¾ì¹ç¤ÈƱÍÍ) ¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ÈƱ¤¸ UTS ̾Á°¶õ´Ö¤Ç
826 ¥×¥í¥»¥¹¤¬ºîÀ®¤µ¤ì¤ë¡£
827 ¤³¤Î¥Õ¥é¥°¤Ï¡¢¥³¥ó¥Æ¥Ê¤Î¼ÂÁõ¤Ç¤Î»ÈÍѤò°Õ¿Þ¤·¤ÆÍÑ°Õ¤µ¤ì¤¿¤â¤Î¤Ç¤¢¤ë¡£
829 .\"O A UTS namespace is the set of identifiers returned by
831 .\"O among these, the domain name and the host name can be modified by
832 .\"O .BR setdomainname (2)
835 .\"O .BR sethostname (2),
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.
842 ¤¬ÊÖ¤¹¼±Ê̻Ҥν¸¹ç¤Ç¤¢¤ë¡£
843 ¼±Ê̻ҤȤ·¤Æ¤Ï¥É¥á¥¤¥ó̾¤È¥Û¥¹¥È̾¤¬¤¢¤ê¡¢
845 .BR setdomainname (2),
847 ¤Ç½¤Àµ¤¹¤ë¤³¤È¤¬¤Ç¤¤ë¡£
848 ¤¢¤ë UTS ̾Á°¶õ´Ö¤Ë¤ª¤±¤ë¼±Ê̻ҤÎÊѹ¹¤ÏƱ¤¸Ì¾Á°¶õ´Ö¤Î¾¤Î¤¹¤Ù¤Æ¤Î
849 ¥×¥í¥»¥¹¤Ë¸«¤¨¤ë¤¬¡¢Ê̤ΠUTS ̾Á°¶õ´Ö¤Î¥×¥í¥»¥¹¤Ë¤Ï¸«¤¨¤Ê¤¤¡£
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 ¤³¤Î¥Õ¥é¥°¤ò»ÈÍѤ¹¤ë¤¿¤á¤Ë¤Ï¡¢
858 ¤ò͸ú¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤³¤È¡¢
860 .RB ( CAP_SYS_ADMIN )
861 ¤ò»ý¤Ã¤Æ¤¤¤ë¤³¤È¤¬É¬ÍפǤ¢¤ë¡£
863 .\"O .BR CLONE_PARENT " (since Linux 2.3.12)"
864 .BR CLONE_PARENT " (Linux 2.3.12 °Ê¹ß)"
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.
871 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢¿·¤·¤¤»Ò¶¡¤Î
873 ¤ÇÊÖ¤µ¤ì¤ë) ¿Æ¥×¥í¥»¥¹¤Ï¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î¿Æ¥×¥í¥»¥¹¤ÈƱ¤¸¤Ë¤Ê¤ë¡£
877 .\"O is not set, then (as with
879 .\"O the child's parent is the calling process.
881 ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢
883 ¤ÈƱÍͤË) ¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤¬¤½¤Î»Ò¶¡¤Î¿Æ¤Ë¤Ê¤ë¡£
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
890 .\"O is set, then the parent of the calling process, rather than the
891 .\"O calling process itself, will be signaled.
892 »Ò¶¡¤¬½ªÎ»¤·¤¿»þ¤Ë¥·¥°¥Ê¥ë¤¬Á÷¤é¤ì¤ë¤Î¤Ï
894 ¤¬ÊÖ¤¹¿Æ¥×¥í¥»¥¹¤Ç¤¢¤ëÅÀ¤ËÃí°Õ¤¹¤ë¤³¤È¡£¤³¤Î¤¿¤á
896 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Ç¤Ï¤Ê¤¯¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î
897 ¿Æ¥×¥í¥»¥¹¤Ë¥·¥°¥Ê¥ë¤¬Á÷¤é¤ì¤ë¡£
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
903 .\"O in parent and child memory.
904 .\"O (In Linux 2.5.32-2.5.48 there was a flag
907 ¿Æ¥×¥í¥»¥¹¤È»Ò¥×¥í¥»¥¹¤Î¥á¥â¥êÆâ¤Î
909 ¤¬»Ø¤¹Îΰè¤Ë»Ò¥×¥í¥»¥¹¤Î¥¹¥ì¥Ã¥É ID ¤ò³ÊǼ¤¹¤ë¡£
910 (Linux 2.5.32-2.5.48 ¤Ç¤Ï¡¢
913 ¤È¤¤¤¦¥Õ¥é¥°¤¬Â¸ºß¤·¤¿¡£)
915 .\"O .BR CLONE_PID " (obsolete)"
916 .BR 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.
927 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢»Ò¥×¥í¥»¥¹¤Ï¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ÈƱ¤¸¥×¥í¥»¥¹ ID
928 ¤ÇºîÀ®¤µ¤ì¤ë¡£¤³¤ì¤Ï¥·¥¹¥Æ¥à¤ò¥Ï¥Ã¥¥ó¥°¤¹¤ë¤Î¤Ë¤ÏÊØÍø¤À¤¬¡¢
929 ¤½¤ì°Ê³°¤Ë¤Ï¤¢¤Þ¤ê»È¤ï¤ì¤Ê¤¤¡£ Linux 2.3.21 °Ê¹ß¤Ç¤Ï¡¢
930 ¥·¥¹¥Æ¥à¤Î¥Ö¡¼¥È¥×¥í¥»¥¹ (PID 0) ¤À¤±¤¬¤³¤Î¥Õ¥é¥°¤ò»ØÄê¤Ç¤¤ë¡£
931 Linux 2.5.16 ¤Çºï½ü¤µ¤ì¤¿¡£
936 .\"O is specified, and the calling process is being traced,
937 .\"O then trace the child also (see
938 .\"O .BR ptrace (2)).
940 ¤¬»ØÄꤵ¤ì¡¢¤«¤Ä¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤¬ÄÉÀ× (trace) ¤µ¤ì¤Æ¤¤¤¿¾ì¹ç¡¢»Ò¥×¥í¥»¥¹¤â
945 .\"O .BR CLONE_SETTLS " (since Linux 2.5.32)"
946 .BR CLONE_SETTLS " (Linux 2.5.32 °Ê¹ß)"
949 .\"O argument is the new TLS (Thread Local Storage) descriptor.
951 .\"O .BR set_thread_area (2).)
953 °ú¤¿ô¤Ï¡¢¿·¤·¤¤ TLS (Thread Local Storage) ¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç¤¢¤ë¡£
954 .RB ( set_thread_area (2)
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
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.
973 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤È»Ò¥×¥í¥»¥¹¤ÏƱ¤¸¥·¥°¥Ê¥ë¡¦¥Ï¥ó
974 ¥É¥é¤Î¥Æ¡¼¥Ö¥ë¤ò¶¦Í¤¹¤ë¡£¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Þ¤¿¤Ï»Ò¥×¥í¥»¥¹¤Î¤É¤Á¤é¤«¤¬
976 ¤ò¸Æ¤Ó½Ð¤·¤Æ¥·¥°¥Ê¥ë¤ËÂбþ¤¹¤ëÆ°ºî¤òÊѹ¹¤·¤¿¾ì¹ç¡¢
977 ¤â¤¦°ìÊý¤Î¥×¥í¥»¥¹¤Î¥·¥°¥Ê¥ëÆ°ºî¤âÊѹ¹¤µ¤ì¤ë¡£
978 ⤷¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤È»Ò¥×¥í¥»¥¹¤Ï¡¢
979 ¥×¥í¥»¥¹Ëè¤Ë¡¢¥·¥°¥Ê¥ë¡¦¥Þ¥¹¥¯ (signal mask) ¤È½èÍýÂÔ¤Á¥·¥°¥Ê¥ë¤Î½¸¹ç
980 ¤ò»ý¤Ã¤Æ¤¤¤ë¡£¤³¤Î¤¿¤á¡¢¤¢¤ë¥×¥í¥»¥¹¤Ï¡¢
982 ¤ò»ÈÍѤ·¤Æ¡¢¤â¤¦°ìÊý¤Î¥×¥í¥»¥¹¤Ë±Æ¶Á¤òÍ¿¤¨¤º¤Ë
983 ¥·¥°¥Ê¥ë¤ò¶Ø»ß (block) ¤·¤¿¤êµö²Ä (unblock) ¤·¤¿¤ê¤Ç¤¤ë¡£
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
992 .\"O .BR sigaction (2)
993 .\"O performed later by one of the processes have no effect on the other
996 ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢»Ò¥×¥í¥»¥¹¤Ï
998 ¤¬¼Â¹Ô¤µ¤ì¤¿»þÅÀ¤Ç¤Î¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î¥·¥°¥Ê¥ë¡¦¥Ï¥ó¥É¥é¤Î
999 ¥³¥Ô¡¼¤ò·Ñ¾µ¤¹¤ë¡£¤³¤ì°Ê¹ß¤Ï¡¢°ìÊý¤Î¥×¥í¥»¥¹¤¬
1001 ¤ò¸Æ¤Ó½Ð¤·¤Æ¤â¡¢¤â¤¦°ìÊý¤Î¥×¥í¥»¥¹¤Ë¤Ï±Æ¶Á¤òÍ¿¤¨¤Ê¤¤¡£
1003 .\"O Since Linux 2.6.0-test6,
1005 .\"O must also include
1008 .\"O .B CLONE_SIGHAND
1010 Linux 2.6.0-test6 °Ê¹ß¤Ç¤Ï¡¢
1016 ¤Ë´Þ¤á¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
1018 .\"O .BR CLONE_STOPPED " (since Linux 2.6.0-test2)"
1019 .BR CLONE_STOPPED " (Linux 2.6.0-test2 °Ê¹ß)"
1021 .\"O .B CLONE_STOPPED
1022 .\"O is set, then the child is initially stopped (as though it was sent a
1024 .\"O signal), and must be resumed by sending it a
1028 ¤¬ÀßÄꤵ¤ì¤ë¤È¡¢»Ò¥×¥í¥»¥¹¤ÏºÇ½é
1030 ¥·¥°¥Ê¥ë¤òÁ÷¤é¤ì¤¿¤«¤Î¤è¤¦¤Ë) Ää»ß¤·¤¿¾õÂ֤Ȥʤ롣
1031 »Ò¥×¥í¥»¥¹¤òºÆ³«¤µ¤»¤ë¤Ë¤Ï
1033 ¥·¥°¥Ê¥ë¤òÁ÷¿®¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
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
1044 .\"O .BR CLONE_SYSVSEM " (since Linux 2.5.10)"
1045 .BR CLONE_SYSVSEM " (Linux 2.5.10 °Ê¹ß)"
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.
1054 ¤¬¥»¥Ã¥È¤µ¤ì¤ë¤È¡¢»Ò¥×¥í¥»¥¹¤È¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Ï°ì¤Ä¤Î
1055 System V ¥»¥Þ¥Õ¥©¤Î¥¢¥ó¥É¥¥Ãͥꥹ¥È
1057 »²¾È) ¤ò¶¦Í¤¹¤ë¡£¤³¤Î¥Õ¥é¥°¤¬¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢
1058 »Ò¥×¥í¥»¥¹¤ÏÆȼ«¤Î¥¢¥ó¥É¥¥¥ê¥¹¥È¤ò»ý¤Ä (¥ê¥¹¥È¤Î½é´üÃͤ϶õ¤Ç¤¢¤ë)¡£
1060 .\"O .BR CLONE_THREAD " (since Linux 2.4.0-test8)"
1061 .BR CLONE_THREAD " (Linux 2.4.0-test8°Ê¹ß)"
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.
1070 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢»Ò¥×¥í¥»¥¹¤Ï¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ÈƱ¤¸¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Ë
1073 ¤Ë¤Ä¤¤¤Æ¤Î°Ê¹ß¤ÎµÄÏÀ¤òÆɤߤ䤹¤¯¤¹¤ë¤¿¤á¡¢
1074 ¡Ö¥¹¥ì¥Ã¥É¡×¤È¤¤¤¦ÍѸì¤Ï¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤ÎÃæ¤Î¥×¥í¥»¥¹¤ò
1075 »²¾È¤¹¤ë¤Î¤Ë»È¤¦¤³¤È¤È¤¹¤ë¡£
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
1083 .\"O return the TGID of the caller.
1084 ¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Ï¡¢ ¥¹¥ì¥Ã¥É½¸¹ç¤Ç°ì¤Ä¤Î PID ¤ò¶¦Í¤¹¤ë¤È¤¤¤¦ POSIX
1085 ¥¹¥ì¥Ã¥É¤Î³µÇ°¤ò¥µ¥Ý¡¼¥È¤¹¤ë¤¿¤á¤Ë Linux 2.4 ¤Ë²Ã¤¨¤é¤ì¤¿µ¡Ç½¤Ç¤¢¤Ã¤¿¡£
1086 ÆâÉôŪ¤Ë¤Ï¡¢¤³¤Î¶¦Í PID ¤Ï¤¤¤ï¤æ¤ë¤½¤Î¥¹¥ì¥Ã¥É¥°¥ë¡¼¥×¤Î
1087 ¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¼±ÊÌ»Ò (TGID) ¤Ç¤¢¤ë¡£
1088 Linux 2.4 °Ê¹ß¤Ç¤Ï¡¢
1090 ¤Î¸Æ¤Ó½Ð¤·¤Ç¤Ï¤½¤Î¥×¥í¥»¥¹¤Î¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥× ID ¤òÊÖ¤¹¡£
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
1097 .\"O and a thread can obtain
1098 .\"O its own TID using
1099 .\"O .BR gettid (2).
1100 ¤¢¤ë¥°¥ë¡¼¥×¤Ë°¤¹¤ë¥¹¥ì¥Ã¥É¤Ï (¥·¥¹¥Æ¥àÁ´ÂΤÇ) °ì°Õ¤Ê¥¹¥ì¥Ã¥É ID (TID)
1101 ¤Ç¶èÊ̤Ǥ¤ë¡£¿·¤·¤¤¥¹¥ì¥Ã¥É¤Î TID ¤Ï
1103 ¤Î¸Æ¤Ó½Ð¤·¸µ¤Ø´Ø¿ô¤Î·ë²Ì¤È¤·¤ÆÊÖ¤µ¤ì¡¢
1104 ¥¹¥ì¥Ã¥É¤Ï¼«Ê¬¼«¿È¤Î TID ¤ò
1108 .\"O When a call is made to
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
1116 .\"O of the new thread group.
1120 ¤Î¸Æ¤Ó½Ð¤·¤¬¹Ô¤ï¤ì¤ë¤È¡¢
1121 À¸À®¤µ¤ì¤¿¥¹¥ì¥Ã¥É¤Ï¤½¤Î¥¹¥ì¥Ã¥É¤Î TID ¤ÈƱ¤¸ÃͤΠTGID ¤ò»ý¤Ä
1122 ¿·¤·¤¤¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤ËÃÖ¤«¤ì¤ë¡£¤³¤Î¥¹¥ì¥Ã¥É¤Ï
1123 ¿·¤·¤¤¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Î¡Ö¥ê¡¼¥À¡¼¡×¤Ç¤¢¤ë¡£
1125 .\"O A new thread created with
1126 .\"O .B CLONE_THREAD
1127 .\"O has the same parent process as the caller of
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.
1135 ¤ò»ØÄꤷ¤ÆºîÀ®¤µ¤ì¤¿¿·¤·¤¤¥¹¥ì¥Ã¥É¤Ï¡¢
1139 ¤ò¸Æ¤Ó½Ð¤·¸µ¤ÈƱ¤¸¿Æ¥×¥í¥»¥¹¤ò»ý¤Ä¡£
1142 ¤ò¸Æ¤Ö¤È¡¢°ì¤Ä¤Î¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Ë°¤¹¥¹¥ì¥Ã¥É¤ÏÁ´¤ÆƱ¤¸ÃͤòÊÖ¤¹¡£
1144 .\"O .B CLONE_THREAD
1145 .\"O thread terminates, the thread that created it using
1149 .\"O (or other termination) signal;
1150 .\"O nor can the status of such a thread be obtained
1153 .\"O (The thread is said to be
1154 .\"O .IR detached .)
1156 ¤Çºî¤é¤ì¤¿¥¹¥ì¥Ã¥É¤¬½ªÎ»¤·¤¿ºÝ¤Ë¡¢
1159 ¤ò»È¤Ã¤ÆÀ¸À®¤·¤¿¥¹¥ì¥Ã¥É¤Ë¤Ï
1161 (¤â¤·¤¯¤Ï¾¤Î½ªÎ»¥·¥°¥Ê¥ë) ¤ÏÁ÷¿®¤µ¤ì¤Ê¤¤¡£
1164 ¤ò»È¤Ã¤Æ½ªÎ»¤·¤¿¥¹¥ì¥Ã¥É¤Î¾õÂÖ¤ò¼èÆÀ¤¹¤ë¤³¤È¤â¤Ç¤¤Ê¤¤
1165 (¤½¤Î¤è¤¦¤Ê¥¹¥ì¥Ã¥É¤Ï
1167 (ʬΥ¤µ¤ì¤¿) ¤È¤¤¤ï¤ì¤ë)¡£
1169 .\"O After all of the threads in a thread group terminate
1170 .\"O the parent process of the thread group is sent a
1172 .\"O (or other termination) signal.
1173 ¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Ë°¤¹Á´¤Æ¤Î¥¹¥ì¥Ã¥É¤¬½ªÎ»¤·¤¿¸å¡¢
1174 ¤½¤Î¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Î¿Æ¥×¥í¥»¥¹¤Ë
1176 (¤â¤·¤¯¤Ï¾¤Î½ªÎ»¥·¥°¥Ê¥ë) ¤¬Á÷¤é¤ì¤ë¡£
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 ¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Ë°¤¹¤¤¤º¤ì¤«¤Î¥¹¥ì¥Ã¥É¤¬
1184 ¤ò¼Â¹Ô¤¹¤ë¤È¡¢¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¡¦¥ê¡¼¥À¡¼°Ê³°¤ÎÁ´¤Æ¤Î¥¹¥ì¥Ã¥É¤Ï
1185 ½ªÎ»¤µ¤ì¡¢¿·¤·¤¤¥×¥í¥»¥¹¤¬¤½¤Î¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¡¦¥ê¡¼¥À¡¼¤Î²¼¤Ç
1188 .\"O If one of the threads in a thread group creates a child using
1190 .\"O then any thread in the group can
1192 .\"O for that child.
1193 ¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Ë°¤¹¥¹¥ì¥Ã¥É¤Î°ì¤Ä¤¬
1195 ¤ò»È¤Ã¤Æ»Ò¥×¥í¥»¥¹¤òºîÀ®¤·¤¿¾ì¹ç¡¢
1196 ¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Î¤É¤Î¥¹¥ì¥Ã¥É¤Ç¤¢¤Ã¤Æ¤â
1201 .\"O Since Linux 2.5.35,
1203 .\"O must also include
1204 .\"O .B CLONE_SIGHAND
1206 .\"O .B CLONE_THREAD
1208 Linux 2.5.35 °Ê¹ß¤Ç¤Ï¡¢
1214 ¤â´Þ¤Þ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
1216 .\"O Signals may be sent to a thread group as a whole (i.e., a TGID) using
1218 .\"O or to a specific thread (i.e., TID) using
1219 .\"O .BR tgkill (2).
1221 ¤ò»È¤Ã¤Æ¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×Á´ÂÎ (¤Ä¤Þ¤ê TGID) ¤Ë¥·¥°¥Ê¥ë¤òÁ÷¤ë¤³¤È¤â¤Ç¤¤ì¤Ð¡¢
1223 ¤ò»È¤Ã¤ÆÆÃÄê¤Î¥¹¥ì¥Ã¥É (¤Ä¤Þ¤ê TID) ¤Ë¥·¥°¥Ê¥ë¤òÁ÷¤ë¤³¤È¤â¤Ç¤¤ë¡£
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 (½ªÎ»¤·¤¿¤ê¡¢Ää»ß¤·¤¿¤ê¡¢Æ°ºî¤ò·Ñ³¤·¤¿¤ê¡¢Ìµ»ë¤µ¤ì¤¿¤ê¤¹¤ë)¡£
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),
1240 .\"O or for an individual thread, when sent with
1241 .\"O .BR tgkill (2).
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 ³Æ¡¹¤Î¥¹¥ì¥Ã¥É¤ÏÆȼ«¤Î¥·¥°¥Ê¥ë¥Þ¥¹¥¯¤ò»ý¤Ã¤Æ¤ª¤ê¡¢
1249 ¤À¤¬¡¢½èÍýÂÔ¤Á¤Î¥·¥°¥Ê¥ë¤Ë¤Ï¡¢
1251 ¤ÇÁ÷¿®¤µ¤ì¤ë¥×¥í¥»¥¹Á´ÂΤËÂФ¹¤ë¤â¤Î (¤Ä¤Þ¤ê¡¢¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Î
1252 ¤É¤Î¥á¥ó¥Ð¡¼¤Ë¤âÇÛÁ÷¤Ç¤¤ë¤â¤Î) ¤È¡¢
1254 ¤ÇÁ÷¿®¤µ¤ì¤ë¸Ä¡¹¤Î¥¹¥ì¥Ã¥É¤ËÂФ¹¤ë¤â¤Î¤¬¤¢¤ê¤¨¤ë¡£
1256 ¤ò¸Æ¤Ó½Ð¤¹¤È¡¢¥×¥í¥»¥¹Á´ÂΤËÂФ¹¤ë½èÍýÂÔ¤Á¥·¥°¥Ê¥ë¤È¸Æ¤Ó½Ð¤·¸µ¤Î
1257 ¥¹¥ì¥Ã¥É¤ËÂФ¹¤ë½èÍýÂÔ¤Á¥·¥°¥Ê¥ë¤ò·ë¹ç¤·¤¿¥·¥°¥Ê¥ë½¸¹ç¤¬ÊÖ¤µ¤ì¤ë¡£
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
1271 ¤ò»È¤Ã¤Æ¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Ë¥·¥°¥Ê¥ë¤¬Á÷¤é¤ì¤¿¾ì¹ç¤Ç¡¢
1272 ¤½¤Î¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤¬¤½¤Î¥·¥°¥Ê¥ë¤ËÂФ¹¤ë¥·¥°¥Ê¥ë¡¦¥Ï¥ó¥É¥é¤¬
1273 ÅÐÏ¿¤µ¤ì¤Æ¤¤¤¿¤È¤¤Ë¤Ï¡¢¥·¥°¥Ê¥ë¡¦¥Ï¥ó¥É¥é¤Ï¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Î
1274 ¥á¥ó¥Ð¡¼¤Î¤¦¤Á¡¢¤¿¤À°ì¤Ä¤Î¥¹¥ì¥Ã¥É¤Ç¤À¤±µ¯Æ°¤µ¤ì¤ë¡£¥Ï¥ó¥É¥é¤¬
1275 µ¯Æ°¤µ¤ì¤ë¥¹¥ì¥Ã¥É¤Ï¡¢¤½¤Î¥·¥°¥Ê¥ë¤ò¶Ø»ß (block) ¤·¤Æ¤¤¤Ê¤¤
1276 ¥á¥ó¥Ð¡¼¤ÎÃ椫¤é°ì¤Ä¤À¤±¤¬¾¡¼ê¤Ë (arbitrarily) Áª¤Ð¤ì¤ë¡£
1277 ¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Ë°¤¹Ê£¿ô¤Î¥¹¥ì¥Ã¥É¤¬
1279 ¤ò»È¤Ã¤ÆƱ¤¸¥·¥°¥Ê¥ë¤òÂԤäƤ¤¤ë¾ì¹ç¡¢
1280 ¤³¤ì¤é¤Î¥¹¥ì¥Ã¥É¤ÎÃ椫¤é°ì¤Ä¤ò¥«¡¼¥Í¥ë¤¬¾¡¼ê¤ËÁªÂò¤·¡¢
1283 ¤ò»È¤Ã¤ÆÁ÷¿®¤µ¤ì¤¿¥·¥°¥Ê¥ë¤ò¼õ¿®¤¹¤ë¡£
1285 .\"O .BR CLONE_UNTRACED " (since Linux 2.5.46)"
1286 .BR CLONE_UNTRACED " (Linux 2.5.46 °Ê¹ß)"
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.
1293 ¤¬»ØÄꤵ¤ì¤ë¤È¡¢ trace ¤ò¹Ô¤Ã¤Æ¤¤¤ë¥×¥í¥»¥¹¤Ï
1296 ¤òŬÍѤ¹¤ë¤³¤È¤¬¤Ç¤¤Ê¤¤¡£
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
1308 .\"O .BR vfork (2)).
1312 ¤ÈƱÍͤË) »Ò¥×¥í¥»¥¹¤¬
1316 ¤Ë¤è¤Ã¤Æ²¾ÁÛ¥á¥â¥ê¤ò²òÊü¤¹¤ë¤Þ¤Ç¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î¼Â¹Ô¤ÏÄä»ß¤µ¤ì¤ë¡£
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.
1324 ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢
1326 ¸Æ¤Ó½Ð¤·¸å¤Ï¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤È»Ò¥×¥í¥»¥¹¤Î
1327 ξÊý¤¬¥¹¥±¥¸¥å¡¼¥ëÂоݤȤʤꡢ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï¤³¤ì¤é¤Î¥×¥í¥»¥¹¤Î
1328 ¼Â¹Ô½ç½ø¤Ë°Í¸¤·¤Ê¤¤¤è¤¦¤Ë¤¹¤Ù¤¤Ç¤¢¤ë¡£
1333 .\"O is set, the calling process and the child process run in the same memory
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
1341 .\"O by the child or calling process also affects the other process.
1343 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤È»Ò¥×¥í¥»¥¹¤ÏƱ¤¸¥á¥â¥ê¶õ´Ö¤Ç
1344 ¼Â¹Ô¤µ¤ì¤ë¡£Æäˡ¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ä»Ò¥×¥í¥»¥¹¤Î°ìÊý¤¬¥á¥â¥ê¤Ë
1345 ½ñ¤¹þ¤ó¤ÀÆâÍƤϤ⤦°ìÊý¤Î¥×¥í¥»¥¹¤«¤é¤â¸«¤ë¤³¤È¤¬¤Ç¤¤ë¡£¤µ¤é¤Ë¡¢
1346 »Ò¥×¥í¥»¥¹¤ä¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î°ìÊý¤¬
1350 ¤ò»È¤Ã¤Æ¥á¥â¥ê¤ò¥Þ¥Ã¥×¤·¤¿¤ê¥¢¥ó¥Þ¥Ã¥×¤·¤¿¾ì¹ç¡¢
1351 ¤â¤¦°ìÊý¤Î¥×¥í¥»¥¹¤Ë¤â±Æ¶Á¤¬µÚ¤Ö¡£
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
1358 .\"O Memory writes or file mappings/unmappings performed by one of the
1359 .\"O processes do not affect the other, as with
1362 ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢»Ò¥×¥í¥»¥¹¤Ï
1364 ¤¬¼Â¹Ô¤µ¤ì¤¿»þÅÀ¤Ç¤Î¡¢¿Æ¥×¥í¥»¥¹¤Î¥á¥â¥ê¶õ´Ö¤ò¥³¥Ô¡¼¤·¤¿
1365 Ê̤Υá¥â¥ê¶õ´Ö¤Ç¼Â¹Ô¤µ¤ì¤ë¡£
1366 °ìÊý¤Î¥×¥í¥»¥¹¤¬¹Ô¤Ã¤¿¥á¥â¥ê¤Ø¤Î½ñ¤¹þ¤ß¤ä
1367 ¥Õ¥¡¥¤¥ë¤Î¥Þ¥Ã¥×/¥¢¥ó¥Þ¥Ã¥×¤Ï¡¢
1369 ¤Î¾ì¹ç¤ÈƱÍÍ¡¢¤â¤¦°ìÊý¤Î¥×¥í¥»¥¹¤Ë¤Ï±Æ¶Á¤·¤Ê¤¤¡£
1373 .\"O system call corresponds more closely to
1375 .\"O in that execution in the child continues from the point of the
1379 .\"O only requires the
1383 .\"O arguments, which have the same meaning as for
1385 .\"O (Note that the order of these arguments differs from
1388 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï¡¢¤è¤ê
1390 ¤Ë¶á¤¤¤«¤¿¤Á¤Ë¤Ê¤Ã¤Æ¤ª¤ê¡¢»Ò¥×¥í¥»¥¹¤Î¼Â¹Ô¤¬¸Æ¤Ó½Ð¤·¤¬¹Ô¤ï¤ì¤¿¾ì½ê¤«¤é
1394 ¤¬É¬ÍפȤ¹¤ë°ú¤¿ô¤Ï
1398 ¤À¤±¤Ç¤¢¤ê¡¢¤½¤ì¤é¤Ï
1401 (¤³¤ì¤é¤Î°ú¤¿ô¤Î½çÈÖ¤Ï
1403 ¤È¤Ï°Û¤Ê¤ë¤³¤È¤ËÃí°Õ¤»¤è)¡£
1405 .\"O Another difference for
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
1412 .\"O In this case, for correct operation, the
1414 .\"O option should not be specified.
1416 ¤Î¤â¤¦°ì¤Ä¤Î°ã¤¤¤Ï¡¢
1418 °ú¤¿ô¤¬¥¼¥í¤Ç¤âÎɤ¤¤³¤È¤Ç¤¢¤ë¡£¤³¤Î¾ì¹ç¤Ë¤Ï¡¢¤É¤Á¤é¤«¤Î¥×¥í¥»¥¹¤¬
1419 ¥¹¥¿¥Ã¥¯¤òÊѹ¹¤·¤¿»þ¤Ë¡¢½ñ¤¹þ¤ß»þ¥³¥Ô¡¼ (copy-on-write) Êý¼°¤Ë¤è¤ê
1420 »Ò¥×¥í¥»¥¹¤¬¥¹¥¿¥Ã¥¯¡¦¥Ú¡¼¥¸¤ÎÆÈΩ¤·¤¿¥³¥Ô¡¼¤òÆÀ¤é¤ì¤ë¤³¤È¤¬Êݾڤµ¤ì¤ë¡£
1421 ¤³¤Î¾ì¹ç¡¢Àµ¾ï¤ËÆ°ºî¤µ¤»¤ë¤¿¤á¤Ë¤Ï¡¢
1423 ¥ª¥×¥·¥ç¥ó¤ò»ØÄꤷ¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
1425 .\"O In Linux 2.4 and earlier,
1427 .\"O does not take arguments
1432 Linux 2.4 °ÊÁ°¤Ç¤Ï¡¢
1439 .\"O .SH "RETURN VALUE"
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
1448 .\"O will be set appropriately.
1449 .\" gettid(2) ¤Ï current->pid ¤òÊÖ¤¹
1450 .\" getpid(2) ¤Ï current->tgid ¤òÊÖ¤¹
1451 À®¸ù¤·¤¿¾ì¹ç¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¼Â¹Ô¥¹¥ì¥Ã¥É¤Ë¤Ï»Ò¥×¥í¥»¥¹¤Î¥¹¥ì¥Ã¥ÉID ¤¬ÊÖ¤µ¤ì¤ë¡£
1452 ¼ºÇÔ¤·¤¿¾ì¹ç¡¢ ¸Æ¤Ó½Ð¤·¸µ¤Î¥³¥ó¥Æ¥¥¹¥È¤Ë¤Ï \-1 ¤¬ÊÖ¤µ¤ì¡¢»Ò¥×¥í¥»¥¹¤Ï
1455 ¤¬Å¬ÀÚ¤ËÀßÄꤵ¤ì¤ë¡£
1460 .\"O Too many processes are already running.
1461 ¤¹¤Ç¤Ë¼Â¹ÔÃæ¤Î¥×¥í¥»¥¹¤¬Â¿¤¹¤®¤ë¡£
1464 .\"O .B CLONE_SIGHAND
1465 .\"O was specified, but
1468 .\"O (Since Linux 2.6.0-test6.)
1470 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤¿¤¬¡¢
1472 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤«¤Ã¤¿¡£
1473 (Linux 2.6.0-test6 °Ê¹ß)
1476 .\"O .B CLONE_THREAD
1477 .\"O was specified, but
1478 .\"O .B CLONE_SIGHAND
1480 .\"O (Since Linux 2.5.35.)
1482 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤¿¤¬¡¢
1484 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤«¤Ã¤¿¡£
1488 .\"O .\" Precisely one of
1489 .\"O .\" .B CLONE_DETACHED
1491 .\"O .\" .B CLONE_THREAD
1492 .\"O .\" was specified.
1493 .\"O .\" (Since Linux 2.6.0-test6.)
1494 .\" .B CLONE_DETACHED
1497 .\" ¤Î¤¤¤º¤ì¤«°ìÊý¤À¤±¤¬»ØÄꤵ¤ì¤¿¡£
1498 .\" (Linux 2.6.0-test6 °Ê¹ß)
1505 .\"O were specified in
1516 .\"O .B CLONE_NEWIPC
1518 .\"O .B CLONE_SYSVSEM
1519 .\"O were specified in
1530 .\"O .BR CLONE_NEWPID
1532 .\"O .BR CLONE_THREAD
1533 .\"O were specified in
1545 .\"O when a zero value is specified for
1546 .\"O .IR child_stack .
1548 ¤Ë¥¼¥í¤ò»ØÄꤷ¤¿¾ì¹ç¤Ë
1553 .\"O .BR CLONE_NEWIPC
1554 .\"O was specified in
1556 .\"O but the kernel was not configured with the
1557 .\"O .B CONFIG_SYSVIPC
1559 .\"O .BR CONFIG_IPC_NS
1564 ¤¬»ØÄꤵ¤ì¤¿¤¬¡¢¥«¡¼¥Í¥ë¤Ç¥ª¥×¥·¥ç¥ó
1568 ¤¬Í¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤Ê¤«¤Ã¤¿¡£
1571 .\"O .BR CLONE_NEWNET
1572 .\"O was specified in
1574 .\"O but the kernel was not configured with the
1575 .\"O .B CONFIG_NET_NS
1580 ¤¬»ØÄꤵ¤ì¤¿¤¬¡¢¥«¡¼¥Í¥ë¤Ç¥ª¥×¥·¥ç¥ó
1582 ¤¬Í¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤Ê¤«¤Ã¤¿¡£
1585 .\"O .BR CLONE_NEWPID
1586 .\"O was specified in
1588 .\"O but the kernel was not configured with the
1589 .\"O .B CONFIG_PID_NS
1594 ¤¬»ØÄꤵ¤ì¤¿¤¬¡¢¥«¡¼¥Í¥ë¤Ç¥ª¥×¥·¥ç¥ó
1596 ¤¬Í¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤Ê¤«¤Ã¤¿¡£
1599 .\"O .BR CLONE_NEWUTS
1600 .\"O was specified in
1602 .\"O but the kernel was not configured with the
1608 ¤¬»ØÄꤵ¤ì¤¿¤¬¡¢¥«¡¼¥Í¥ë¤Ç¥ª¥×¥·¥ç¥ó
1610 ¤¬Í¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤Ê¤«¤Ã¤¿¡£
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
1616 »Ò¥×¥í¥»¥¹¤Î¤¿¤á¤Ë³ÎÊݤ¹¤Ù¤¥¿¥¹¥¯¹½Â¤ÂΤ䡢¸Æ¤Ó½Ð¤·¸µ¤Î¥³¥ó¥Æ¥¥¹¥È¤Î
1617 °ìÉô¤ò¥³¥Ô¡¼¤¹¤ë¤Î¤ËɬÍפʥá¥â¥ê¤ò½½Ê¬¤Ë³ä¤êÅö¤Æ¤ë¤³¤È¤¬¤Ç¤¤Ê¤¤¡£
1620 .\"O .BR CLONE_NEWIPC ,
1621 .\"O .BR CLONE_NEWNET ,
1622 .\"O .BR CLONE_NEWNS ,
1623 .\"O .BR CLONE_NEWPID ,
1625 .\"O .BR CLONE_NEWUTS
1626 .\"O was specified by an unprivileged process (process without \fBCAP_SYS_ADMIN\fP).
1627 ÈóÆø¢¥×¥í¥»¥¹ (\fBCAP_SYS_ADMIN\fP ¤ò»ý¤¿¤Ê¤¤¥×¥í¥»¥¹) ¤¬
1637 .\"O was specified by a process other than process 0.
1638 PID ¤¬ 0 °Ê³°¤Î¥×¥í¥»¥¹¤Ë¤è¤Ã¤Æ
1643 .\"O There is no entry for
1646 .\"O glibc2 provides
1648 .\"O as described in this manual page.
1653 ¤¬Ä󶡤µ¤ì¤Æ¤ª¤ê¡¢¤³¤Î¥Þ¥Ë¥å¥¢¥ë¥Ú¡¼¥¸¤ËµºÜ¤ÎÄ̤ê¤Ç¤¢¤ë¡£
1654 .\"O .SH "CONFORMING TO"
1660 .\"O calls are Linux-specific and should not be used in programs
1661 .\"O intended to be portable.
1665 ¥³¡¼¥ë¤Ï Linux ÆÃͤǤ¢¤ê¡¢°Ü¿¢¤ò¹Íθ¤·¤¿¥×¥í¥°¥é¥à¤Ç¤Ï»ÈÍѤ¹¤Ù¤
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 ·ÏÎó¤Ç¤Ï¡¢°ìÈÌŪ¤Ë¤Ï
1680 ¥Õ¥é¥°¤ò»ØÄꤷ¤Æ¤â¿·¤·¤¤¥¹¥ì¥Ã¥É¤Î¿Æ¤ò
1681 ¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Î¿Æ¤ÈƱ¤¸¤Ë¤Ï¤·¤Ê¤¤¡£
1682 ¤·¤«¤·¡¢¥Ð¡¼¥¸¥ç¥ó 2.4.7¡Á2.4.18 ¤Î¥«¡¼¥Í¥ë¤Ç¤Ï¡¢
1683 (¥«¡¼¥Í¥ë 2.6 ¤ÈƱ¤¸¤è¤¦¤Ë) CLONE_THREAD ¥Õ¥é¥°¤ò»ØÄꤹ¤ë¤È¡¢
1684 °ÅÌۤΤ¦¤Á¤Ë CLONE_PARENT ¥Õ¥é¥°¤ò»ØÄꤷ¤¿¤³¤È¤Ë¤Ê¤ë¡£
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
1692 .\"O .B CLONE_THREAD
1694 .\"O This flag is still defined, but has no effect.
1696 ¤È¤¤¤¦¥Õ¥é¥°¤¬¡¢2.5.32 ¤ÇƳÆþ¤µ¤ì¤Æ°ÊÍ褷¤Ð¤é¤¯¤Î´Ö¸ºß¤·¤¿¡£
1697 ¤³¤Î¥Õ¥é¥°¤Ï¿Æ¥×¥í¥»¥¹¤¬»Ò¥×¥í¥»¥¹½ªÎ»¤Î¥·¥°¥Ê¥ë¤òɬÍפȤ·¤Ê¤¤¤³¤È¤ò
1699 2.6.2 ¤Ç¡¢ CLONE_DETATCHED ¤ò CLONE_THREAD ¤È°ì½ï¤Ë»ØÄꤹ¤ëɬÍפϤʤ¯¤Ê¤Ã¤¿¡£
1700 ¤³¤Î¥Õ¥é¥°¤Ï¤Þ¤ÀÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤¬¡¢²¿¤Î¸ú²Ì¤â¤Ê¤¤¡£
1704 .\"O should not be called through vsyscall, but directly through
1705 .\"O .IR "int $0x80" .
1708 ¤Ï vsyscall ·Ðͳ¤Ç¤Ï¤Ê¤¯¡¢Ä¾ÀÜ
1710 ·Ðͳ¤Ç¸Æ¤Ó½Ð¤¹¤Ù¤¤Ç¤¢¤ë¡£
1712 .\"O On ia64, a different system call is used:
1713 ia64 ¤Ç¤Ï¡¢Ê̤Υ·¥¹¥Æ¥à¥³¡¼¥ë¤¬»ÈÍѤµ¤ì¤ë:
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 " */ );"
1724 .\"O .BR __clone2 ()
1725 .\"O system call operates in the same way as
1728 .\"O .I child_stack_base
1729 .\"O points to the lowest address of the child's stack area,
1732 .\"O specifies the size of the stack pointed to by
1733 .\"O .IR child_stack_base .
1737 ¤ÈƱ¤¸¤è¤¦¤ËÆ°ºî¤¹¤ë¤¬¡¢°Ê²¼¤ÎÅÀ¤¬°Û¤Ê¤ë:
1739 ¤Ï»Ò¥×¥í¥»¥¹¤Î¥¹¥¿¥Ã¥¯¥¨¥ê¥¢¤ÎºÇ¾®¤Î¥¢¥É¥ì¥¹¤ò»Ø¤·¡¢
1743 ¤¬»Ø¤·¼¨¤¹¥¹¥¿¥Ã¥¯¥¨¥ê¥¢¤ÎÂ礤µ¤ò¼¨¤¹¡£
1746 .\"O Versions of the GNU C library that include the NPTL threading library
1747 .\"O contain a wrapper function for
1749 .\"O that performs caching of PIDs.
1750 NPTL ¥¹¥ì¥Ã¥É¡¦¥é¥¤¥Ö¥é¥ê¤ò´Þ¤ó¤Ç¤¤¤ë GNU C ¥é¥¤¥Ö¥é¥ê¤Î¤¤¤¯¤Ä¤«¤Î¥Ð¡¼¥¸¥ç¥ó
1753 ¤Î¥é¥Ã¥Ñ¡¼´Ø¿ô¤¬´Þ¤Þ¤ì¤Æ¤ª¤ê¡¢¤³¤Î¥é¥Ã¥Ñ¡¼´Ø¿ô¤Ï PID ¤ò¥¥ã¥Ã¥·¥å¤¹¤ë¡£
1754 .\"O This caching relies on support in the glibc wrapper for
1756 .\"O but as currently implemented,
1757 .\"O the cache may not be up to date in some circumstances.
1758 ¤³¤Î¥¥ã¥Ã¥·¥å½èÍý¤¬Àµ¤·¤¯Æ°ºî¤¹¤ë¤¿¤á¤Ë¤Ï glibc ¤Î
1760 ¤Î¥é¥Ã¥Ñ¡¼´Ø¿ô¤Ç¤Î½õ¤±¤¬É¬ÍפÀ¤¬¡¢¸½¾õ¤Î¼ÂÁõ¤Ç¤Ï¡¢
1761 ¤¢¤ë¾õ¶·²¼¤Ë¤ª¤¤¤Æ¥¥ã¥Ã¥·¥å¤¬ºÇ¿·¤È¤Ê¤é¤Ê¤¤²ÄǽÀ¤¬¤¢¤ë¡£
1763 .\"O if a signal is delivered to the child immediately after the
1765 .\"O call, then a call to
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.
1773 ¤Î¸Æ¤Ó½Ð¤·Ä¾¸å¤Ë¥·¥°¥Ê¥ë¤¬»Ò¥×¥í¥»¥¹¤ËÇÛÁ÷¤µ¤ì¤¿¾ì¹ç¤Ë¡¢
1774 ¤½¤Î¥·¥°¥Ê¥ë¤ËÂФ¹¤ë¥Ï¥ó¥É¥éÆâ¤Ç
1776 ¤ò¸Æ¤Ó½Ð¤¹¤È¡¢¤½¤ì¤Þ¤Ç¤Ë clone ¤Î¥é¥Ã¥Ñ¡¼´Ø¿ô¤¬»Ò¥×¥í¥»¥¹¤Î PID ¥¥ã¥Ã¥·¥å¤ò
1777 ¹¹¿·¤¹¤ëµ¡²ñ¤¬ÆÀ¤é¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹ ("¿Æ¥×¥í¥»¥¹") ¤Î PID ¤¬
1778 ÊÖ¤µ¤ì¤ë²ÄǽÀ¤¬¤¢¤ë¡£
1779 .\"O (This discussion ignores the case where the child was created using
1780 .\"O .BR CLONE_THREAD ,
1784 .\"O return the same value in the child and in the process that called
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
1789 .\"O argument includes
1790 .\"O .BR CLONE_VM .)
1791 (¤³¤ÎµÄÏÀ¤Ç¤Ï¡¢»Ò¥×¥í¥»¥¹¤¬
1793 ¤ò»È¤Ã¤ÆºîÀ®¤µ¤ì¤¿¾ì¹ç¤Î¤³¤È¤Ï̵»ë¤·¤Æ¤¤¤ë¡£
1796 ¤òºî¤Ã¤ÆºîÀ®¤µ¤ì¤¿¾ì¹ç¤Ë¤Ï¡¢
1797 ¸Æ¤Ó½Ð¤·¸µ¤È»Ò¥×¥í¥»¥¹¤ÏƱ¤¸¥¹¥ì¥Ã¥É¡¦¥°¥ë¡¼¥×¤Ë°¤¹¤Î¤Ç¡¢
1801 ¤ò¸Æ¤Ó½Ð¤·¤¿¥×¥í¥»¥¹¤ÇƱ¤¸ÃͤòÊÖ¤¹¤Î¤¬¡ÖÀµ¤·¤¤¡×¡£
1802 ¥¥ã¥Ã¥·¥å¤¬ºÇ¿·¤È¤Ê¤é¤Ê¤¤ÌäÂê (stale-cache problem) ¤Ï¡¢
1806 ¤¬´Þ¤Þ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤âȯÀ¸¤·¤Ê¤¤¡£)
1807 .\"O To get the truth, it may be necessary to use code such as the following:
1808 ËÜÅö¤ÎÃͤòÆÀ¤ë¤¿¤á¤Ë¤Ï¡¢¼¡¤Î¤è¤¦¤Ê¥³¡¼¥É¤ò»È¤¦É¬Íפ¬¤¢¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
1811 #include <syscall.h>
1815 mypid = syscall(SYS_getpid);
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
1826 .BR set_thread_area (2),
1827 .BR set_tid_address (2),
1831 .BR capabilities (7),