#, fuzzy msgid "" msgstr "" "Project-Id-Version: man-pages-l10n VERSION\n" "POT-Creation-Date: 2014-07-17 17:53+0900\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #. type: TH #: man-pages/man2/clone.2:45 #, no-wrap msgid "CLONE" msgstr "" #. type: TH #: man-pages/man2/clone.2:45 #, no-wrap msgid "2014-05-28" msgstr "" #. type: TH #: man-pages/man2/clone.2:45 #, no-wrap msgid "Linux" msgstr "" #. type: TH #: man-pages/man2/clone.2:45 #, no-wrap msgid "Linux Programmer's Manual" msgstr "" #. type: SH #: man-pages/man2/clone.2:46 #, no-wrap msgid "NAME" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:48 msgid "clone, __clone2 - create a child process" msgstr "" #. type: SH #: man-pages/man2/clone.2:48 #, no-wrap msgid "SYNOPSIS" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:51 #, no-wrap msgid "/* Prototype for the glibc wrapper function */\n" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:53 #, no-wrap msgid "B<#include Esched.hE>\n" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:58 #, no-wrap msgid "" "BIB<)(void *), void *>IB<,>\n" "B< int >IB<, void *>IB<, ... >\n" "B< /* pid_t *>IB<, struct user_desc *>IB<, pid_t " "*>IB< */ );>\n" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:60 #, no-wrap msgid "/* Prototype for the raw system call */\n" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:64 #, no-wrap msgid "" "BIB<, void *>IB<,>\n" "B< void *>IB<, void *>IB<,>\n" "B< struct pt_regs *>IB<);>\n" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:69 msgid "" "Feature Test Macro Requirements for glibc wrapper function (see " "B(7)):" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:72 msgid "B():" msgstr "" #. type: TP #: man-pages/man2/clone.2:75 #, no-wrap msgid "Since glibc 2.14:" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:78 msgid "_GNU_SOURCE" msgstr "" #. See http://sources.redhat.com/bugzilla/show_bug.cgi?id=4749 #. type: TP #: man-pages/man2/clone.2:78 #, no-wrap msgid "Before glibc 2.14:" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:83 #, no-wrap msgid "_BSD_SOURCE || _SVID_SOURCE\n" " /* _GNU_SOURCE also suffices */\n" msgstr "" #. type: SH #: man-pages/man2/clone.2:86 #, no-wrap msgid "DESCRIPTION" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:90 msgid "B() creates a new process, in a manner similar to B(2)." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:97 msgid "" "This page describes both the glibc B() wrapper function and the " "underlying system call on which it is based. The main text describes the " "wrapper function; the differences for the raw system call are described " "toward the end of this page." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:109 msgid "" "Unlike B(2), B() allows the child process to share parts of " "its execution context with the calling process, such as the memory space, " "the table of file descriptors, and the table of signal handlers. (Note that " "on this manual page, \"calling process\" normally corresponds to \"parent " "process\". But see the description of B below.)" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:114 msgid "" "The main use of B() is to implement threads: multiple threads of " "control in a program that run concurrently in a shared memory space." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:134 msgid "" "When the child process is created with B(), it executes the function " "I(I). (This differs from B(2), where execution continues in " "the child from the point of the B(2) call.) The I argument is a " "pointer to a function that is called by the child process at the beginning " "of its execution. The I argument is passed to the I function." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:144 msgid "" "When the I(I) function application returns, the child process " "terminates. The integer returned by I is the exit code for the child " "process. The child process may also terminate explicitly by calling " "B(2) or after receiving a fatal signal." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:160 msgid "" "The I argument specifies the location of the stack used by the " "child process. Since the child and calling process may share memory, it is " "not possible for the child process to execute in the same stack as the " "calling process. The calling process must therefore set up memory space for " "the child stack and pass a pointer to this space to B(). Stacks grow " "downward on all processors that run Linux (except the HP PA processors), so " "I usually points to the topmost address of the memory space set " "up for the child stack." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:176 msgid "" "The low byte of I contains the number of the I " "sent to the parent when the child dies. If this signal is specified as " "anything other than B, then the parent process must specify the " "B<__WALL> or B<__WCLONE> options when waiting for the child with B(2). " " If no signal is specified, then the parent process is not signaled when the " "child terminates." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:181 msgid "" "I may also be bitwise-or'ed with zero or more of the following " "constants, in order to specify what is shared between the calling process " "and the child process:" msgstr "" #. type: TP #: man-pages/man2/clone.2:181 #, no-wrap msgid "B (since Linux 2.5.49)" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:191 msgid "" "Erase child thread ID at location I in child memory when the child " "exits, and do a wakeup on the futex at that address. The address involved " "may be changed by the B(2) system call. This is used by " "threading libraries." msgstr "" #. type: TP #: man-pages/man2/clone.2:191 #, no-wrap msgid "B (since Linux 2.5.49)" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:196 msgid "Store child thread ID at location I in child memory." msgstr "" #. type: TP #: man-pages/man2/clone.2:196 #, no-wrap msgid "B (since Linux 2.0)" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:209 msgid "" "If B is set, the calling process and the child process share " "the same file descriptor table. Any file descriptor created by the calling " "process or by the child process is also valid in the other process. " "Similarly, if one of the processes closes a file descriptor, or changes its " "associated flags (using the B(2) B operation), the other " "process is also affected." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:223 msgid "" "If B is not set, the child process inherits a copy of all file " "descriptors opened in the calling process at the time of B(). (The " "duplicated file descriptors in the child refer to the same open file " "descriptions (see B(2)) as the corresponding file descriptors in the " "calling process.) Subsequent operations that open or close file " "descriptors, or change file descriptor flags, performed by either the " "calling process or the child process do not affect the other process." msgstr "" #. type: TP #: man-pages/man2/clone.2:223 #, no-wrap msgid "B (since Linux 2.0)" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:238 msgid "" "If B is set, the caller and the child process share the same " "filesystem information. This includes the root of the filesystem, the " "current working directory, and the umask. Any call to B(2), " "B(2), or B(2) performed by the calling process or the child " "process also affects the other process." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:250 msgid "" "If B is not set, the child process works on a copy of the " "filesystem information of the calling process at the time of the B() " "call. Calls to B(2), B(2), B(2) performed later by " "one of the processes do not affect the other process." msgstr "" #. type: TP #: man-pages/man2/clone.2:250 #, no-wrap msgid "B (since Linux 2.6.25)" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:259 msgid "" "If B is set, then the new process shares an I/O context with the " "calling process. If this flag is not set, then (as with B(2)) the " "new process has its own I/O context." msgstr "" #. The following based on text from Jens Axboe #. the anticipatory and CFQ scheduler #. with CFQ and AS. #. type: Plain text #: man-pages/man2/clone.2:276 msgid "" "The I/O context is the I/O scope of the disk scheduler (i.e, what the I/O " "scheduler uses to model scheduling of a process's I/O). If processes share " "the same I/O context, they are treated as one by the I/O scheduler. As a " "consequence, they get to share disk time. For some I/O schedulers, if two " "processes share an I/O context, they will be allowed to interleave their " "disk access. If several threads are doing I/O on behalf of the same process " "(B(3), for instance), they should employ B to get better " "I/O performance." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:280 msgid "" "If the kernel is not configured with the B option, this flag " "is a no-op." msgstr "" #. type: TP #: man-pages/man2/clone.2:280 #, no-wrap msgid "B (since Linux 2.6.19)" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:290 msgid "" "If B is set, then create the process in a new IPC namespace. " "If this flag is not set, then (as with B(2)), the process is created " "in the same IPC namespace as the calling process. This flag is intended for " "the implementation of containers." msgstr "" #. commit 7eafd7c74c3f2e67c27621b987b28397110d643f #. https://lwn.net/Articles/312232/ #. type: Plain text #: man-pages/man2/clone.2:302 msgid "" "An IPC namespace provides an isolated view of System\\ V IPC objects (see " "B(7)) and (since Linux 2.6.30) POSIX message queues (see " "B(7)). The common characteristic of these IPC mechanisms is " "that IPC objects are identified by mechanisms other than filesystem " "pathnames." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:306 msgid "" "Objects created in an IPC namespace are visible to all other processes that " "are members of that namespace, but are not visible to processes in other IPC " "namespaces." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:310 msgid "" "When an IPC namespace is destroyed (i.e., when the last process that is a " "member of the namespace terminates), all IPC objects in the namespace are " "automatically destroyed." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:319 msgid "" "Use of this flag requires: a kernel configured with the B " "and B options and that the process be privileged " "(B). This flag can't be specified in conjunction with " "B." msgstr "" #. type: TP #: man-pages/man2/clone.2:319 #, no-wrap msgid "B (since Linux 2.6.24)" msgstr "" #. FIXME Check when the implementation was completed #. type: Plain text #: man-pages/man2/clone.2:324 msgid "" "(The implementation of this flag was completed only by about kernel version " "2.6.29.)" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:333 msgid "" "If B is set, then create the process in a new network " "namespace. If this flag is not set, then (as with B(2)), the process " "is created in the same network namespace as the calling process. This flag " "is intended for the implementation of containers." msgstr "" #. FIXME Add pointer to veth(4) page when it is eventually completed #. type: Plain text #: man-pages/man2/clone.2:348 msgid "" "A network namespace provides an isolated view of the networking stack " "(network device interfaces, IPv4 and IPv6 protocol stacks, IP routing " "tables, firewall rules, the I and I directory " "trees, sockets, etc.). A physical network device can live in exactly one " "network namespace. A virtual network device (\"veth\") pair provides a pipe-" "like abstraction that can be used to create tunnels between network " "namespaces, and can be used to create a bridge to a physical network device " "in another namespace." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:353 msgid "" "When a network namespace is freed (i.e., when the last process in the " "namespace terminates), its physical network devices are moved back to the " "initial network namespace (not to the parent of the process)." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:358 msgid "" "Use of this flag requires: a kernel configured with the B " "option and that the process be privileged (B)." msgstr "" #. type: TP #: man-pages/man2/clone.2:358 #, no-wrap msgid "B (since Linux 2.4.19)" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:361 msgid "Start the child in a new mount namespace." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:382 msgid "" "Every process lives in a mount namespace. The I of a process is " "the data (the set of mounts) describing the file hierarchy as seen by that " "process. After a B(2) or B() where the B flag " "is not set, the child lives in the same mount namespace as the parent. The " "system calls B(2) and B(2) change the mount namespace of " "the calling process, and hence affect all processes that live in the same " "namespace, but do not affect processes in a different mount namespace." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:389 msgid "" "After a B() where the B flag is set, the cloned child " "is started in a new mount namespace, initialized with a copy of the " "namespace of the parent." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:401 msgid "" "Only a privileged process (one having the B capability) may " "specify the B flag. It is not permitted to specify both " "B and B in the same B() call." msgstr "" #. type: TP #: man-pages/man2/clone.2:401 #, no-wrap msgid "B (since Linux 2.6.24)" msgstr "" #. This explanation draws a lot of details from #. http://lwn.net/Articles/259217/ #. Authors: Pavel Emelyanov #. and Kir Kolyshkin #. The primary kernel commit is 30e49c263e36341b60b735cbef5ca37912549264 #. Author: Pavel Emelyanov #. type: Plain text #: man-pages/man2/clone.2:418 msgid "" "If B is set, then create the process in a new PID namespace. " "If this flag is not set, then (as with B(2)), the process is created " "in the same PID namespace as the calling process. This flag is intended for " "the implementation of containers." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:427 msgid "" "A PID namespace provides an isolated environment for PIDs: PIDs in a new " "namespace start at 1, somewhat like a standalone system, and calls to " "B(2), B(2), or B() will produce processes with PIDs " "that are unique within the namespace." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:439 msgid "" "The first process created in a new namespace (i.e., the process created " "using the B flag) has the PID 1, and is the \"init\" process " "for the namespace. Children that are orphaned within the namespace will be " "reparented to this process rather than B(8). Unlike the traditional " "B process, the \"init\" process of a PID namespace can terminate, and " "if it does, all of the processes in the namespace are terminated." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:458 msgid "" "PID namespaces form a hierarchy. When a new PID namespace is created, the " "processes in that namespace are visible in the PID namespace of the process " "that created the new namespace; analogously, if the parent PID namespace is " "itself the child of another PID namespace, then processes in the child and " "parent PID namespaces will both be visible in the grandparent PID namespace. " " Conversely, the processes in the \"child\" PID namespace do not see the " "processes in the parent namespace. The existence of a namespace hierarchy " "means that each process may now have multiple PIDs: one for each namespace " "in which it is visible; each of these PIDs is unique within the " "corresponding namespace. (A call to B(2) always returns the PID " "associated with the namespace in which the process lives.)" msgstr "" #. mount -t proc proc /proc #. type: Plain text #: man-pages/man2/clone.2:474 msgid "" "After creating the new namespace, it is useful for the child to change its " "root directory and mount a new procfs instance at I so that tools " "such as B(1) work correctly. (If B is also included in " "I, then it isn't necessary to change the root directory: a new procfs " "instance can be mounted directly over I.)" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:481 msgid "" "Use of this flag requires: a kernel configured with the B " "option and that the process be privileged (B). This flag " "can't be specified in conjunction with B." msgstr "" #. type: TP #: man-pages/man2/clone.2:481 #, no-wrap msgid "B (since Linux 2.6.19)" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:493 msgid "" "If B is set, then create the process in a new UTS namespace, " "whose identifiers are initialized by duplicating the identifiers from the " "UTS namespace of the calling process. If this flag is not set, then (as " "with B(2)), the process is created in the same UTS namespace as the " "calling process. This flag is intended for the implementation of containers." "" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:504 msgid "" "A UTS namespace is the set of identifiers returned by B(2); among " "these, the domain name and the hostname can be modified by " "B(2) and B(2), respectively. Changes made to " "the identifiers in a UTS namespace are visible to all other processes in the " "same namespace, but are not visible to processes in other UTS namespaces." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:509 msgid "" "Use of this flag requires: a kernel configured with the B " "option and that the process be privileged (B)." msgstr "" #. type: TP #: man-pages/man2/clone.2:509 #, no-wrap msgid "B (since Linux 2.3.12)" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:516 msgid "" "If B is set, then the parent of the new child (as returned by " "B(2)) will be the same as that of the calling process." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:522 msgid "" "If B is not set, then (as with B(2)) the child's parent " "is the calling process." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:530 msgid "" "Note that it is the parent process, as returned by B(2), which is " "signaled when the child terminates, so that if B is set, then " "the parent of the calling process, rather than the calling process itself, " "will be signaled." msgstr "" #. type: TP #: man-pages/man2/clone.2:530 #, no-wrap msgid "B (since Linux 2.5.49)" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:538 msgid "" "Store child thread ID at location I in parent and child memory. (In " "Linux 2.5.32-2.5.48 there was a flag B that did this.)" msgstr "" #. type: TP #: man-pages/man2/clone.2:538 #, no-wrap msgid "B (obsolete)" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:549 msgid "" "If B is set, the child process is created with the same process " "ID as the calling process. This is good for hacking the system, but " "otherwise of not much use. Since 2.3.21 this flag can be specified only by " "the system boot process (PID 0). It disappeared in Linux 2.5.16." msgstr "" #. type: TP #: man-pages/man2/clone.2:549 #, no-wrap msgid "B (since Linux 2.2)" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:556 msgid "" "If B is specified, and the calling process is being traced, " "then trace the child also (see B(2))." msgstr "" #. type: TP #: man-pages/man2/clone.2:556 #, no-wrap msgid "B (since Linux 2.5.32)" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:563 msgid "" "The I argument is the new TLS (Thread Local Storage) descriptor. " "(See B(2).)" msgstr "" #. type: TP #: man-pages/man2/clone.2:563 #, no-wrap msgid "B (since Linux 2.0)" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:579 msgid "" "If B is set, the calling process and the child process share " "the same table of signal handlers. If the calling process or child process " "calls B(2) to change the behavior associated with a signal, the " "behavior is changed in the other process as well. However, the calling " "process and child processes still have distinct signal masks and sets of " "pending signals. So, one of them may block or unblock some signals using " "B(2) without affecting the other process." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:590 msgid "" "If B is not set, the child process inherits a copy of the " "signal handlers of the calling process at the time B() is called. " "Calls to B(2) performed later by one of the processes have no " "effect on the other process." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:598 msgid "" "Since Linux 2.6.0-test6, I must also include B if " "B is specified" msgstr "" #. type: TP #: man-pages/man2/clone.2:598 #, no-wrap msgid "B (since Linux 2.6.0-test2)" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:607 msgid "" "If B is set, then the child is initially stopped (as though " "it was sent a B signal), and must be resumed by sending it a " "B signal." msgstr "" #. glibc 2.8 removed this defn from bits/sched.h #. type: Plain text #: man-pages/man2/clone.2:615 msgid "" "This flag was I from Linux 2.6.25 onward, and was I " "altogether in Linux 2.6.38." msgstr "" #. type: TP #: man-pages/man2/clone.2:615 #, no-wrap msgid "B (since Linux 2.5.10)" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:624 msgid "" "If B is set, then the child and the calling process share a " "single list of System\\ V semaphore undo values (see B(2)). If this " "flag is not set, then the child has a separate undo list, which is initially " "empty." msgstr "" #. type: TP #: man-pages/man2/clone.2:624 #, no-wrap msgid "B (since Linux 2.4.0-test8)" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:633 msgid "" "If B is set, the child is placed in the same thread group as " "the calling process. To make the remainder of the discussion of " "B more readable, the term \"thread\" is used to refer to the " "processes within a thread group." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:641 msgid "" "Thread groups were a feature added in Linux 2.4 to support the POSIX threads " "notion of a set of threads that share a single PID. Internally, this shared " "PID is the so-called thread group identifier (TGID) for the thread group. " "Since Linux 2.4, calls to B(2) return the TGID of the caller." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:650 msgid "" "The threads within a group can be distinguished by their (system-wide) " "unique thread IDs (TID). A new thread's TID is available as the function " "result returned to the caller of B(), and a thread can obtain its own " "TID using B(2)." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:660 msgid "" "When a call is made to B() without specifying B, then " "the resulting thread is placed in a new thread group whose TGID is the same " "as the thread's TID. This thread is the I of the new thread group." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:682 msgid "" "A new thread created with B has the same parent process as the " "caller of B() (i.e., like B), so that calls to " "B(2) return the same value for all of the threads in a thread " "group. When a B thread terminates, the thread that created it " "using B() is not sent a B (or other termination) signal; " "nor can the status of such a thread be obtained using B(2). (The " "thread is said to be I.)" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:687 msgid "" "After all of the threads in a thread group terminate the parent process of " "the thread group is sent a B (or other termination) signal." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:692 msgid "" "If any of the threads in a thread group performs an B(2), then all " "threads other than the thread group leader are terminated, and the new " "program is executed in the thread group leader." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:698 msgid "" "If one of the threads in a thread group creates a child using B(2), " "then any thread in the group can B(2) for that child." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:711 msgid "" "Since Linux 2.5.35, I must also include B if " "B is specified (and note that, since Linux 2.6.0-test6, " "B also requires B to be included)." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:716 msgid "" "Signals may be sent to a thread group as a whole (i.e., a TGID) using " "B(2), or to a specific thread (i.e., TID) using B(2)." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:721 msgid "" "Signal dispositions and actions are process-wide: if an unhandled signal is " "delivered to a thread, then it will affect (terminate, stop, continue, be " "ignored in) all members of the thread group." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:734 msgid "" "Each thread has its own signal mask, as set by B(2), but " "signals can be pending either: for the whole process (i.e., deliverable to " "any member of the thread group), when sent with B(2); or for an " "individual thread, when sent with B(2). A call to B(2) " "returns a signal set that is the union of the signals pending for the whole " "process and the signals that are pending for the calling thread." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:746 msgid "" "If B(2) is used to send a signal to a thread group, and the thread " "group has installed a handler for the signal, then the handler will be " "invoked in exactly one, arbitrarily selected member of the thread group that " "has not blocked the signal. If multiple threads in a group are waiting to " "accept the same signal using B(2), the kernel will arbitrarily " "select one of these threads to receive a signal sent using B(2)." msgstr "" #. type: TP #: man-pages/man2/clone.2:746 #, no-wrap msgid "B (since Linux 2.5.46)" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:753 msgid "" "If B is specified, then a tracing process cannot force " "B on this child process." msgstr "" #. type: TP #: man-pages/man2/clone.2:753 #, no-wrap msgid "B (since Linux 2.2)" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:765 msgid "" "If B is set, the execution of the calling process is suspended " "until the child releases its virtual memory resources via a call to " "B(2) or B<_exit>(2) (as with B(2))." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:771 msgid "" "If B is not set, then both the calling process and the child " "are schedulable after the call, and an application should not rely on " "execution occurring in any particular order." msgstr "" #. type: TP #: man-pages/man2/clone.2:771 #, no-wrap msgid "B (since Linux 2.0)" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:784 msgid "" "If B is set, the calling process and the child process run in the " "same memory space. In particular, memory writes performed by the calling " "process or by the child process are also visible in the other process. " "Moreover, any memory mapping or unmapping performed with B(2) or " "B(2) by the child or calling process also affects the other process." "" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:793 msgid "" "If B is not set, the child process runs in a separate copy of the " "memory space of the calling process at the time of B(). Memory " "writes or file mappings/unmappings performed by one of the processes do not " "affect the other, as with B(2)." msgstr "" #. type: SS #: man-pages/man2/clone.2:793 #, no-wrap msgid "The raw system call interface" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:809 msgid "" "The raw B() system call corresponds more closely to B(2) in " "that execution in the child continues from the point of the call. As such, " "the I and I arguments of the B() wrapper function are " "omitted. Furthermore, the argument order changes. The raw system call " "interface on x86 and many other architectures is roughly:" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:815 #, no-wrap msgid "" "BIB<, void *>IB<,>\n" "B< void *>IB<, void *>IB<,>\n" "B< struct pt_regs *>IB<);>\n" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:826 msgid "" "Another difference for the raw system call is that the I " "argument may be zero, in which case copy-on-write semantics ensure that the " "child gets separate copies of stack pages when either process modifies the " "stack. In this case, for correct operation, the B option should " "not be specified." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:834 msgid "" "For some architectures, the order of the arguments for the system call " "differs from that shown above. On the score, microblaze, ARM, ARM 64, PA-" "RISC, arc, Power PC, xtensa, and MIPS architectures, the order of the fourth " "and fifth arguments is reversed. On the cris and s390 architectures, the " "order of the first and second arguments is reversed." msgstr "" #. type: SS #: man-pages/man2/clone.2:834 #, no-wrap msgid "blackfin, m68k, and sparc" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:838 msgid "" "The argument-passing conventions on blackfin, m68k, and sparc are different " "from the descriptions above. For details, see the kernel (and glibc) source." "" msgstr "" #. type: SS #: man-pages/man2/clone.2:838 #, no-wrap msgid "ia64" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:840 msgid "On ia64, a different interface is used:" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:847 #, no-wrap msgid "" "BIB<)(void *), >\n" "B< void *>IB<, size_t >IB<,>\n" "B< int >IB<, void *>IB<, ... >\n" "B< /* pid_t *>IB<, struct user_desc *>IB<, pid_t " "*>IB< */ );>\n" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:859 msgid "" "The prototype shown above is for the glibc wrapper function; the raw system " "call interface has no I or I argument, and changes the order of the " "arguments so that I is the first argument, and I is the last " "argument." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:870 msgid "" "B<__clone2>() operates in the same way as B(), except that " "I points to the lowest address of the child's stack area, " "and I specifies the size of the stack pointed to by " "I." msgstr "" #. type: SS #: man-pages/man2/clone.2:870 #, no-wrap msgid "Linux 2.4 and earlier" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:878 msgid "" "In Linux 2.4 and earlier, B() does not take arguments I, " "I, and I." msgstr "" #. type: SH #: man-pages/man2/clone.2:878 #, no-wrap msgid "RETURN VALUE" msgstr "" #. gettid(2) returns current->pid; #. getpid(2) returns current->tgid; #. type: Plain text #: man-pages/man2/clone.2:887 msgid "" "On success, the thread ID of the child process is returned in the caller's " "thread of execution. On failure, -1 is returned in the caller's context, no " "child process will be created, and I will be set appropriately." msgstr "" #. type: SH #: man-pages/man2/clone.2:887 #, no-wrap msgid "ERRORS" msgstr "" #. type: TP #: man-pages/man2/clone.2:888 #, no-wrap msgid "B" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:892 msgid "Too many processes are already running; see B(2)." msgstr "" #. type: TP #: man-pages/man2/clone.2:892 man-pages/man2/clone.2:899 man-pages/man2/clone.2:914 man-pages/man2/clone.2:922 man-pages/man2/clone.2:930 man-pages/man2/clone.2:938 man-pages/man2/clone.2:944 man-pages/man2/clone.2:954 man-pages/man2/clone.2:962 man-pages/man2/clone.2:970 #, no-wrap msgid "B" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:899 msgid "" "B was specified, but B was not. (Since Linux 2.6.0-" "test6.)" msgstr "" #. .TP #. .B EINVAL #. Precisely one of #. .B CLONE_DETACHED #. and #. .B CLONE_THREAD #. was specified. #. (Since Linux 2.6.0-test6.) #. type: Plain text #: man-pages/man2/clone.2:914 msgid "" "B was specified, but B was not. (Since Linux 2." "5.35.)" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:922 msgid "Both B and B were specified in I." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:930 msgid "Both B and B were specified in I." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:938 msgid "Both B and B were specified in I." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:944 msgid "" "Returned by B() when a zero value is specified for I." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:954 msgid "" "B was specified in I, but the kernel was not configured " "with the B and B options." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:962 msgid "" "B was specified in I, but the kernel was not configured " "with the B option." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:970 msgid "" "B was specified in I, but the kernel was not configured " "with the B option." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:978 msgid "" "B was specified in I, but the kernel was not configured " "with the B option." msgstr "" #. type: TP #: man-pages/man2/clone.2:978 #, no-wrap msgid "B" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:983 msgid "" "Cannot allocate sufficient memory to allocate a task structure for the " "child, or to copy those parts of the caller's context that need to be copied." "" msgstr "" #. type: TP #: man-pages/man2/clone.2:983 man-pages/man2/clone.2:992 #, no-wrap msgid "B" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:992 msgid "" "B, B, B, B, or " "B was specified by an unprivileged process (process without " "B)." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:996 msgid "B was specified by a process other than process 0." msgstr "" #. type: SH #: man-pages/man2/clone.2:996 #, no-wrap msgid "VERSIONS" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:1003 msgid "" "There is no entry for B() in libc5. glibc2 provides B() as " "described in this manual page." msgstr "" #. type: SH #: man-pages/man2/clone.2:1003 #, no-wrap msgid "CONFORMING TO" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:1007 msgid "" "B() is Linux-specific and should not be used in programs intended to " "be portable." msgstr "" #. type: SH #: man-pages/man2/clone.2:1007 #, no-wrap msgid "NOTES" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:1017 msgid "" "In the kernel 2.4.x series, B generally does not make the " "parent of the new thread the same as the parent of the calling process. " "However, for kernel versions 2.4.7 to 2.4.18 the B flag " "implied the B flag (as in kernel 2.6)." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:1027 msgid "" "For a while there was B (introduced in 2.5.32): parent wants " "no child-exit signal. In 2.6.2 the need to give this together with " "B disappeared. This flag is still defined, but has no effect." msgstr "" #. type: Plain text #: man-pages/man2/clone.2:1032 msgid "" "On i386, B() should not be called through vsyscall, but directly " "through I." msgstr "" #. type: SH #: man-pages/man2/clone.2:1032 #, no-wrap msgid "BUGS" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:1063 msgid "" "Versions of the GNU C library that include the NPTL threading library " "contain a wrapper function for B(2) that performs caching of PIDs. " "This caching relies on support in the glibc wrapper for B(), but as " "currently implemented, the cache may not be up to date in some circumstances." " In particular, if a signal is delivered to the child immediately after the " "B() call, then a call to B(2) in a handler for the signal " "may return the PID of the calling process (\"the parent\"), if the clone " "wrapper has not yet had a chance to update the PID cache in the child. " "(This discussion ignores the case where the child was created using " "B, when B(2) I return the same value in the " "child and in the process that called B(), since the caller and the " "child are in the same thread group. The stale-cache problem also does not " "occur if the I argument includes B.) To get the truth, it " "may be necessary to use code such as the following:" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:1066 #, no-wrap msgid " #include Esyscall.hE\n" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:1068 #, no-wrap msgid " pid_t mypid;\n" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:1070 #, no-wrap msgid " mypid = syscall(SYS_getpid);\n" msgstr "" #. See also the following bug reports #. https://bugzilla.redhat.com/show_bug.cgi?id=417521 #. http://sourceware.org/bugzilla/show_bug.cgi?id=6910 #. type: SH #: man-pages/man2/clone.2:1074 #, no-wrap msgid "EXAMPLE" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:1084 msgid "" "The following program demonstrates the use of B() to create a child " "process that executes in a separate UTS namespace. The child changes the " "hostname in its UTS namespace. Both parent and child then display the " "system hostname, making it possible to see that the hostname differs in the " "UTS namespaces of the parent and child. For an example of the use of this " "program, see B(2)." msgstr "" #. type: SS #: man-pages/man2/clone.2:1084 #, no-wrap msgid "Program source" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:1094 #, no-wrap msgid "" "#define _GNU_SOURCE\n" "#include Esys/wait.hE\n" "#include Esys/utsname.hE\n" "#include Esched.hE\n" "#include Estring.hE\n" "#include Estdio.hE\n" "#include Estdlib.hE\n" "#include Eunistd.hE\n" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:1097 #, no-wrap msgid "" "#define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); \\e\n" " } while (0)\n" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:1102 #, no-wrap msgid "" "static int /* Start function for cloned child */\n" "childFunc(void *arg)\n" "{\n" " struct utsname uts;\n" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:1104 #, no-wrap msgid " /* Change hostname in UTS namespace of child */\n" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:1107 #, no-wrap msgid "" " if (sethostname(arg, strlen(arg)) == -1)\n" " errExit(\"sethostname\");\n" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:1109 #, no-wrap msgid " /* Retrieve and display hostname */\n" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:1113 #, no-wrap msgid "" " if (uname(&uts) == -1)\n" " errExit(\"uname\");\n" " printf(\"uts.nodename in child: %s\\en\", uts.nodename);\n" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:1117 #, no-wrap msgid "" " /* Keep the namespace open for a while, by sleeping.\n" " This allows some experimentation--for example, another\n" " process might join the namespace. */\n" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:1119 #, no-wrap msgid " sleep(200);\n" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:1122 #, no-wrap msgid " return 0; /* Child terminates now */\n" "}\n" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:1124 #, no-wrap msgid "#define STACK_SIZE (1024 * 1024) /* Stack size for cloned child */\n" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:1132 #, no-wrap msgid "" "int\n" "main(int argc, char *argv[])\n" "{\n" " char *stack; /* Start of stack buffer */\n" " char *stackTop; /* End of stack buffer */\n" " pid_t pid;\n" " struct utsname uts;\n" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:1137 #, no-wrap msgid "" " if (argc E 2) {\n" " fprintf(stderr, \"Usage: %s Echild-hostnameE\\en\", " "argv[0]);\n" " exit(EXIT_SUCCESS);\n" " }\n" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:1139 #, no-wrap msgid " /* Allocate stack for child */\n" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:1144 #, no-wrap msgid "" " stack = malloc(STACK_SIZE);\n" " if (stack == NULL)\n" " errExit(\"malloc\");\n" " stackTop = stack + STACK_SIZE; /* Assume stack grows downward */\n" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:1147 #, no-wrap msgid "" " /* Create child that has its own UTS namespace;\n" " child commences execution in childFunc() */\n" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:1152 #, no-wrap msgid "" " pid = clone(childFunc, stackTop, CLONE_NEWUTS | SIGCHLD, argv[1]);\n" " if (pid == -1)\n" " errExit(\"clone\");\n" " printf(\"clone() returned %ld\\en\", (long) pid);\n" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:1154 #, no-wrap msgid " /* Parent falls through to here */\n" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:1156 #, no-wrap msgid " sleep(1); /* Give child time to change its hostname */\n" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:1159 #, no-wrap msgid "" " /* Display hostname in parent\\(aqs UTS namespace. This will be\n" " different from hostname in child\\(aqs UTS namespace. */\n" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:1163 #, no-wrap msgid "" " if (uname(&uts) == -1)\n" " errExit(\"uname\");\n" " printf(\"uts.nodename in parent: %s\\en\", uts.nodename);\n" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:1167 #, no-wrap msgid "" " if (waitpid(pid, NULL, 0) == -1) /* Wait for child */\n" " errExit(\"waitpid\");\n" " printf(\"child has terminated\\en\");\n" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:1170 #, no-wrap msgid " exit(EXIT_SUCCESS);\n" "}\n" msgstr "" #. type: SH #: man-pages/man2/clone.2:1171 #, no-wrap msgid "SEE ALSO" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:1185 msgid "" "B(2), B(2), B(2), B(2), B(2), " "B(2), B(2), B(2), B(2), " "B(2), B(2), B(7), B(7)" msgstr "" #. type: SH #: man-pages/man2/clone.2:1185 #, no-wrap msgid "COLOPHON" msgstr "" #. type: Plain text #: man-pages/man2/clone.2:1193 msgid "" "This page is part of release 3.70 of the Linux I project. A " "description of the project, information about reporting bugs, and the latest " "version of this page, can be found at \\%http://www.kernel.org/doc/man-pages/" "." msgstr ""