]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/clone.2
clone.2: Add kernel version numbers for clone_args fields
[thirdparty/man-pages.git] / man2 / clone.2
CommitLineData
fea681da 1.\" Copyright (c) 1992 Drew Eckhardt <drew@cs.colorado.edu>, March 28, 1992
fb1fa92b 2.\" and Copyright (c) Michael Kerrisk, 2001, 2002, 2005, 2013, 2019
2297bf0e 3.\"
fd0fc519 4.\" %%%LICENSE_START(GPL_NOVERSION_ONELINE)
fea681da 5.\" May be distributed under the GNU General Public License.
fd0fc519 6.\" %%%LICENSE_END
dccaff1e 7.\"
fea681da
MK
8.\" Modified by Michael Haardt <michael@moria.de>
9.\" Modified 24 Jul 1993 by Rik Faith <faith@cs.unc.edu>
10.\" Modified 21 Aug 1994 by Michael Chastain <mec@shell.portal.com>:
11.\" New man page (copied from 'fork.2').
12.\" Modified 10 June 1995 by Andries Brouwer <aeb@cwi.nl>
13.\" Modified 25 April 1998 by Xavier Leroy <Xavier.Leroy@inria.fr>
14.\" Modified 26 Jun 2001 by Michael Kerrisk
15.\" Mostly upgraded to 2.4.x
16.\" Added prototype for sys_clone() plus description
17.\" Added CLONE_THREAD with a brief description of thread groups
c13182ef 18.\" Added CLONE_PARENT and revised entire page remove ambiguity
fea681da
MK
19.\" between "calling process" and "parent process"
20.\" Added CLONE_PTRACE and CLONE_VFORK
21.\" Added EPERM and EINVAL error codes
fd8a5be4 22.\" Renamed "__clone" to "clone" (which is the prototype in <sched.h>)
fea681da 23.\" various other minor tidy ups and clarifications.
c11b1abf 24.\" Modified 26 Jun 2001 by Michael Kerrisk <mtk.manpages@gmail.com>
d9bfdb9c 25.\" Updated notes for 2.4.7+ behavior of CLONE_THREAD
c11b1abf 26.\" Modified 15 Oct 2002 by Michael Kerrisk <mtk.manpages@gmail.com>
fea681da
MK
27.\" Added description for CLONE_NEWNS, which was added in 2.4.19
28.\" Slightly rephrased, aeb.
29.\" Modified 1 Feb 2003 - added CLONE_SIGHAND restriction, aeb.
30.\" Modified 1 Jan 2004 - various updates, aeb
0967c11f 31.\" Modified 2004-09-10 - added CLONE_PARENT_SETTID etc. - aeb.
d9bfdb9c 32.\" 2005-04-12, mtk, noted the PID caching behavior of NPTL's getpid()
31830ef0 33.\" wrapper under BUGS.
fd8a5be4
MK
34.\" 2005-05-10, mtk, added CLONE_SYSVSEM, CLONE_UNTRACED, CLONE_STOPPED.
35.\" 2005-05-17, mtk, Substantially enhanced discussion of CLONE_THREAD.
4e836144 36.\" 2008-11-18, mtk, order CLONE_* flags alphabetically
82ee147a 37.\" 2008-11-18, mtk, document CLONE_NEWPID
43ce9dda 38.\" 2008-11-19, mtk, document CLONE_NEWUTS
667417b3 39.\" 2008-11-19, mtk, document CLONE_NEWIPC
cfdc761b 40.\" 2008-11-19, Jens Axboe, mtk, document CLONE_IO
fea681da 41.\"
a5409de9 42.TH CLONE 2 2019-11-19 "Linux" "Linux Programmer's Manual"
fea681da 43.SH NAME
a9e52b43 44clone, __clone2, clone3 \- create a child process
fea681da 45.SH SYNOPSIS
c10859eb 46.nf
81f10dad 47/* Prototype for the glibc wrapper function */
dbfe9c70 48.PP
4f71ba5d 49.B #define _GNU_SOURCE
fea681da 50.B #include <sched.h>
dbfe9c70 51.PP
81c2368f
MK
52.BI "int clone(int (*" "fn" ")(void *), void *" stack \
53", int " flags ", void *" "arg" ", ... "
54.BI " /* pid_t *" parent_tid ", void *" tls \
55", pid_t *" child_tid " */ );"
dbfe9c70 56.PP
faa0e55a
MK
57/* For the prototype of the raw clone() system call, see NOTES */
58.PP
75e28eba 59.BI "long clone3(struct clone_args *" cl_args ", size_t " size );
c10859eb 60.fi
faa0e55a
MK
61.PP
62.IR Note :
63There is not yet a glibc wrapper for
64.BR clone3 ();
65see NOTES.
fea681da 66.SH DESCRIPTION
faa0e55a 67These system calls
8dd6b0bc 68create a new ("child") process, in a manner similar to
fea681da 69.BR fork (2).
efeece04 70.PP
8dd6b0bc 71By contrast with
fea681da 72.BR fork (2),
225f5da8 73these system calls provide more precise control over what pieces of execution
10337567
MK
74context are shared between the calling process and the child process.
75For example, using these system calls, the caller can control whether
76or not the two processes share the virtual address space,
77the table of file descriptors, and the table of signal handlers.
225f5da8 78These system calls also allow the new child process to be placed
10337567
MK
79in separate
80.BR namespaces (7).
81.PP
82Note that in this manual
c13182ef 83page, "calling process" normally corresponds to "parent process".
a10c5a33 84But see the descriptions of
c13182ef 85.B CLONE_PARENT
a10c5a33
MK
86and
87.B CLONE_THREAD
10337567 88below.
efeece04 89.PP
faa0e55a
MK
90This page describes the following interfaces:
91.IP * 3
92The glibc
93.BR clone ()
94wrapper function and the underlying system call on which it is based.
95The main text describes the wrapper function;
96the differences for the raw system call
97are described toward the end of this page.
98.IP *
99The newer
100.BR clone3 ()
101system call.
5261b0fe
MK
102.PP
103In the remainder of this page, the terminology "the clone call" is used
324f6154 104when noting details that apply to all of these interfaces,
faa0e55a
MK
105.\"
106.SS The clone() wrapper function
107.PP
108When the child process is created with the
109.BR clone ()
110wrapper function,
7495cbc7
MK
111it commences execution by calling the function pointed to by the argument
112.IR fn .
fea681da 113(This differs from
c13182ef 114.BR fork (2),
fea681da 115where execution continues in the child from the point
c13182ef
MK
116of the
117.BR fork (2)
fea681da
MK
118call.)
119The
fea681da 120.I arg
7495cbc7
MK
121argument is passed as the argument of the function
122.IR fn .
efeece04 123.PP
c13182ef 124When the
fea681da 125.IR fn ( arg )
4ba17a6d 126function returns, the child process terminates.
c13182ef 127The integer returned by
fea681da 128.I fn
4ba17a6d 129is the exit status for the child process.
c13182ef 130The child process may also terminate explicitly by calling
fea681da
MK
131.BR exit (2)
132or after receiving a fatal signal.
efeece04 133.PP
fea681da 134The
81c2368f 135.I stack
c13182ef
MK
136argument specifies the location of the stack used by the child process.
137Since the child and calling process may share memory,
fea681da 138it is not possible for the child process to execute in the
c13182ef
MK
139same stack as the calling process.
140The calling process must therefore
fea681da
MK
141set up memory space for the child stack and pass a pointer to this
142space to
edcc65ff 143.BR clone ().
5fab2e7c 144Stacks grow downward on all processors that run Linux
fea681da 145(except the HP PA processors), so
81c2368f 146.I stack
fea681da
MK
147usually points to the topmost address of the memory space set up for
148the child stack.
faa0e55a
MK
149Note that
150.BR clone ()
151does not provide a means whereby the caller can inform the kernel of the
152size of the stack area.
153.PP
154The remaining arguments to
155.BR clone ()
156are discussed below.
157.\"
158.SS clone3()
159.PP
160The
161.BR clone3 ()
162system call provides a superset of the functionality of the older
163.BR clone ()
164interface.
165It also provides a number of API improvements, including:
166space for additional flags bits;
167cleaner separation in the use of various arguments;
168and the ability to specify the size of the child's stack area.
169.PP
170As with
171.BR fork (2),
172.BR clone3 ()
173returns in both the parent and the child.
174It returns 0 in the child process and returns the PID of the child
175in the parent.
176.PP
177The
178.I cl_args
179argument of
180.BR clone3 ()
181is a structure of the following form:
182.PP
183.in +4n
184.EX
185struct clone_args {
186 u64 flags; /* Flags bit mask */
187 u64 pidfd; /* Where to store PID file descriptor
be66dbc7 188 (\fIpid_t *\fP) */
faa0e55a 189 u64 child_tid; /* Where to store child TID,
be66dbc7 190 in child's memory (\fIpid_t *\fP) */
faa0e55a
MK
191 u64 parent_tid; /* Where to store child TID,
192 in parent's memory (\fIint *\fP) */
193 u64 exit_signal; /* Signal to deliver to parent on
194 child termination */
195 u64 stack; /* Pointer to lowest byte of stack */
196 u64 stack_size; /* Size of stack */
197 u64 tls; /* Location of new TLS */
f7d5e082
MK
198 u64 set_tid; /* Pointer to a \fIpid_t\fP array
199 (since Linux 5.5) */
200 u64 set_tid_size; /* Number of elements in \fIset_tid\fP
201 (since Linux 5.5) */
202 u64 cgroup; /* Target cgroup file descriptor for the
203 child process (since Linux 5.7) */
faa0e55a
MK
204};
205.EE
206.in
207.PP
208The
209.I size
210argument that is supplied to
211.BR clone3 ()
212should be initialized to the size of this structure.
213(The existence of the
214.I size
215argument permits future extensions to the
216.IR clone_args
217structure.)
218.PP
219The stack for the child process is specified via
220.IR cl_args.stack ,
221which points to the lowest byte of the stack area,
222and
223.IR cl_args.stack_size ,
224which specifies the size of the stack in bytes.
225In the case where the
226.BR CLONE_VM
227flag (see below) is specified, a stack must be explicitly allocated
228and specified.
229Otherwise, these two fields can be specified as NULL and 0,
230which causes the child to use the same stack area as the parent
231(in the child's own virtual address space).
232.PP
233The remaining fields in the
234.I cl_args
235argument are discussed below.
236.\"
237.SS Equivalence between clone() and clone3() arguments
238.PP
239Unlike the older
240.BR clone ()
241interface, where arguments are passed individually, in the newer
242.BR clone3 ()
243interface the arguments are packaged into the
244.I clone_args
245structure shown above.
246This structure allows for a superset of the information passed via the
247.BR clone ()
248arguments.
249.PP
250The following table shows the equivalence between the arguments of
251.BR clone ()
252and the fields in the
253.I clone_args
254argument supplied to
255.BR clone3 ():
256.RS
257.TS
258lb lb lb
259l l l
260li li l.
97883fae 261clone() clone3() Notes
faa0e55a 262 \fIcl_args\fP field
f5d5180f 263flags & ~0xff flags For most flags; details below
faa0e55a
MK
264parent_tid pidfd See CLONE_PIDFD
265child_tid child_tid See CLONE_CHILD_SETTID
266parent_tid parent_tid See CLONE_PARENT_SETTID
267flags & 0xff exit_signal
268stack stack
269\fP---\fP stack_size
270tls tls See CLONE_SETTLS
bf031aaa
AR
271\fP---\fP set_tid See below for details
272\fP---\fP set_tid_size
faa0e55a
MK
273.TE
274.RE
5fbce8f2
MK
275.\"
276.SS The child termination signal
efeece04 277.PP
faa0e55a
MK
278When the child process terminates, a signal may be sent to the parent.
279The termination signal is specified in the low byte of
fea681da 280.I flags
faa0e55a
MK
281.RB ( clone ())
282or in
283.I cl_args.exit_signal
284.RB ( clone3 ()).
fd8a5be4 285If this signal is specified as anything other than
fea681da
MK
286.BR SIGCHLD ,
287then the parent process must specify the
c13182ef
MK
288.B __WALL
289or
fea681da 290.B __WCLONE
c13182ef
MK
291options when waiting for the child with
292.BR wait (2).
faa0e55a 293If no signal (i.e., zero) is specified, then the parent process is not signaled
fea681da 294when the child terminates.
5fbce8f2 295.\"
bf031aaa
AR
296.SS The set_tid array
297.PP
298By default, the kernel chooses the next sequential PID for the new
299process in each of the PID namespaces where it is present.
300When creating a process with
301.BR clone3 (),
302the
303.I set_tid
b386cee3
MK
304array (available since Linux 5.5)
305can be used to select specific PIDs for the process in some
bf031aaa 306or all of the PID namespaces where it is present.
ee8bb310 307If the PID of the newly created process should be set only for the current
bf031aaa
AR
308PID namespace or in the newly created PID namespace (if
309.I flags
310contains
311.BR CLONE_NEWPID )
312then the first element in the
313.I set_tid
314array has to be the desired PID and
315.I set_tid_size
316needs to be 1.
317.PP
318If the PID of the newly created process should have a certain value in
ee8bb310 319multiple PID namespaces, then the
bf031aaa 320.I set_tid
09007c4b
MK
321array can have multiple entries.
322The first entry defines the PID in the most
ee8bb310
MK
323deeply nested PID namespace and each of the following entries contains
324the PID in the
325corresponding ancestor PID namespace.
09007c4b 326The number of PID namespaces in which a PID
bf031aaa
AR
327should be set is defined by
328.I set_tid_size
329which cannot be larger than the number of currently nested PID namespaces.
330.PP
331To create a process with the following PIDs in a PID namespace hierarchy:
332.RS
333.TS
ee8bb310
MK
334lb lb lb
335l l l.
336PID NS level Requested PID Notes
3370 31496 Outermost PID namespace
bf031aaa 3381 42
ee8bb310 3392 7 Innermost PID namespace
bf031aaa
AR
340.TE
341.RE
342.PP
343Set the array to:
344.PP
ee8bb310 345.in +4n
bf031aaa 346.EX
ee8bb310
MK
347set_tid[0] = 7;
348set_tid[1] = 42;
349set_tid[2] = 31496;
350set_tid_size = 3;
bf031aaa 351.EE
ee8bb310 352.in
bf031aaa
AR
353.PP
354If only the PIDs in the two innermost PID namespaces
355need to be specified, set the array to:
356.PP
ee8bb310 357.in +4n
bf031aaa 358.EX
ee8bb310
MK
359set_tid[0] = 7;
360set_tid[1] = 42;
361set_tid_size = 2;
bf031aaa 362.EE
ee8bb310 363.in
bf031aaa
AR
364.PP
365The PID in the PID namespaces outside the two innermost PID namespaces
366will be selected the same way as any other PID is selected.
367.PP
368The
369.I set_tid
370feature requires
ee8bb310 371.BR CAP_SYS_ADMIN
bf031aaa
AR
372in all owning user namespaces of the target PID namespaces.
373.PP
ee8bb310
MK
374Callers may only choose a PID greater than 1 in a given PID namespace
375if an
376.BR init
377process (i.e., a process with PID 1) already exists in that namespace.
09007c4b 378Otherwise the PID
bf031aaa
AR
379entry for this PID namespace must be 1.
380.\"
16853a31 381.SS The flags mask
efeece04 382.PP
faa0e55a
MK
383Both
384.BR clone ()
385and
386.BR clone3 ()
387allow a flags bit mask that modifies their behavior
388and allows the caller to specify what is shared between the calling process
389and the child process.
5261b0fe
MK
390This bit mask\(emthe
391.I flags
392argument of
393.BR clone ()
394or the
395.I cl_args.flags
396field passed to
397.BR clone3 ()\(emis
16853a31
MK
398referred to as the
399.I flags
400mask in the remainder of this page.
401.PP
402The
403.I flags
404mask is specified as a bitwise-OR of zero or more of
405the constants listed below.
5261b0fe 406Except as noted below, these flags are available
faa0e55a
MK
407(and have the same effect) in both
408.BR clone ()
409and
410.BR clone3 ().
fea681da 411.TP
f5dbc7c8 412.BR CLONE_CHILD_CLEARTID " (since Linux 2.5.49)"
e2bf1234 413Clear (zero) the child thread ID at the location pointed to by
81c2368f 414.I child_tid
faa0e55a
MK
415.RB ( clone ())
416or
417.I cl_args.child_tid
418.RB ( clone3 ())
f5dbc7c8
MK
419in child memory when the child exits, and do a wakeup on the futex
420at that address.
421The address involved may be changed by the
422.BR set_tid_address (2)
423system call.
424This is used by threading libraries.
425.TP
426.BR CLONE_CHILD_SETTID " (since Linux 2.5.49)"
e2bf1234 427Store the child thread ID at the location pointed to by
81c2368f 428.I child_tid
faa0e55a
MK
429.RB ( clone ())
430or
431.I cl_args.child_tid
432.RB ( clone3 ())
8ef021ea 433in the child's memory.
5261b0fe 434The store operation completes before the clone call
6ab62ed8 435returns control to user space in the child process.
5261b0fe 436(Note that the store operation may not have completed before the clone call
6ab62ed8
MK
437returns in the parent process, which will be relevant if the
438.BR CLONE_VM
439flag is also employed.)
f5dbc7c8 440.TP
27f14b44
MK
441.BR CLONE_CLEAR_SIGHAND " (since Linux 5.5)"
442.\" commit b612e5df4587c934bd056bf05f4a1deca4de4f75
443By default, signal dispositions in the child thread are the same as
444in the parent.
445If this flag is specified,
446then all signals that are handled in the parent
447are reset to their default dispositions
448.RB ( SIG_DFL )
449in the child.
450.IP
451Specifying this flag together with
452.B CLONE_SIGHAND
453is nonsensical and disallowed.
454.TP
aed3cc90
CB
455.BR CLONE_INTO_CGROUP " (since Linux 5.7)"
456.\" commit ef2c41cf38a7559bbf91af42d5b6a4429db8fc68
5c216c0f 457By default, a child process is placed in the same version 2
aed3cc90 458cgroup as its parent.
5c216c0f
MK
459If this flag is specified, the child process will be created in a
460different version 2 cgroup than its parent.
461(Note that
aed3cc90 462.BR CLONE_INTO_CGROUP
5c216c0f
MK
463has effect only for version 2 cgroups.)
464.IP
465In order to place the child process in a different version 2 cgroup,
466the caller specifies
aed3cc90
CB
467.BR CLONE_INTO_CGROUP
468in
469.I cl_args.flags
5c216c0f 470and passes a directory file descriptor (see the
aed3cc90
CB
471.BR O_DIRECTORY
472flag for the
473.BR open (2)
474syscall) in the
5c216c0f
MK
475.I cl_args.cgroup
476field.
aed3cc90
CB
477The caller may also pass an
478.BR O_PATH
479(see
480.BR open (2))
481file descriptor for the target cgroup.
482Note, that all usual version 2 cgroup migration restrictions (see
483.BR cgroups (7)
484for details) apply.
5c216c0f 485.IP
aed3cc90
CB
486Spawning a process into a cgroup different from the parent's cgroup
487makes it possible for a service manager to directly spawn new
b19679f7 488services into dedicated cgroups.
5c216c0f
MK
489This eliminates the accounting
490jitter that would be caused by the new process living in the
491parent's cgroup for a short time before being
b19679f7 492moved into the target cgroup.
5c216c0f
MK
493The
494.BR CLONE_INTO_CGROUP
495flag also allows the creation of
496frozen child processes by spawning them into a frozen cgroup.
497(See
aed3cc90 498.BR cgroups (7)
5c216c0f
MK
499for a description of the freezer controller.)
500For threaded applications (or even thread implementations which
501make use of cgroups to limit individual threads), it is possible to
aed3cc90
CB
502establish a fixed cgroup layout before spawning each thread
503directly into its target cgroup.
504.TP
baa435c6
MK
505.BR CLONE_DETACHED " (historical)"
506For a while (during the Linux 2.5 development series)
507.\" added in 2.5.32; removed in 2.6.0-test4
508there was a
509.B CLONE_DETACHED
510flag,
511which caused the parent not to receive a signal when the child terminated.
512Ultimately, the effect of this flag was subsumed under the
513.BR CLONE_THREAD
514flag and by the time Linux 2.6.0 was released, this flag had no effect.
515Starting in Linux 2.6.2, the need to give this flag together with
516.B CLONE_THREAD
517disappeared.
518.IP
519This flag is still defined, but it is usually ignored when calling
520.BR clone ().
521However, see the description of
522.BR CLONE_PIDFD
523for some exceptions.
524.TP
1603d6a1 525.BR CLONE_FILES " (since Linux 2.0)"
fea681da 526If
f5dbc7c8
MK
527.B CLONE_FILES
528is set, the calling process and the child process share the same file
529descriptor table.
530Any file descriptor created by the calling process or by the child
531process is also valid in the other process.
532Similarly, if one of the processes closes a file descriptor,
533or changes its associated flags (using the
534.BR fcntl (2)
535.B F_SETFD
536operation), the other process is also affected.
8a76b19e
KE
537If a process sharing a file descriptor table calls
538.BR execve (2),
539its file descriptor table is duplicated (unshared).
efeece04 540.IP
fea681da 541If
f5dbc7c8
MK
542.B CLONE_FILES
543is not set, the child process inherits a copy of all file descriptors
5261b0fe 544opened in the calling process at the time of the clone call.
f5dbc7c8
MK
545Subsequent operations that open or close file descriptors,
546or change file descriptor flags,
547performed by either the calling
548process or the child process do not affect the other process.
db8ba2b4 549Note, however,
839d161f
MK
550that the duplicated file descriptors in the child refer to the same
551open file descriptions as the corresponding file descriptors
552in the calling process,
2433365b 553and thus share file offsets and file status flags (see
db8ba2b4 554.BR open (2)).
fea681da 555.TP
1603d6a1 556.BR CLONE_FS " (since Linux 2.0)"
fea681da
MK
557If
558.B CLONE_FS
9ee4a2b6 559is set, the caller and the child process share the same filesystem
c13182ef 560information.
9ee4a2b6 561This includes the root of the filesystem, the current
c13182ef
MK
562working directory, and the umask.
563Any call to
fea681da
MK
564.BR chroot (2),
565.BR chdir (2),
566or
567.BR umask (2)
edcc65ff 568performed by the calling process or the child process also affects the
fea681da 569other process.
efeece04 570.IP
c13182ef 571If
fea681da 572.B CLONE_FS
9ee4a2b6 573is not set, the child process works on a copy of the filesystem
5261b0fe 574information of the calling process at the time of the clone call.
fea681da
MK
575Calls to
576.BR chroot (2),
577.BR chdir (2),
4ba17a6d 578or
fea681da
MK
579.BR umask (2)
580performed later by one of the processes do not affect the other process.
fea681da 581.TP
a4cc375e 582.BR CLONE_IO " (since Linux 2.6.25)"
11f27a1c
JA
583If
584.B CLONE_IO
585is set, then the new process shares an I/O context with
586the calling process.
587If this flag is not set, then (as with
588.BR fork (2))
589the new process has its own I/O context.
efeece04 590.IP
11f27a1c 591.\" The following based on text from Jens Axboe
d1f84ed7 592The I/O context is the I/O scope of the disk scheduler (i.e.,
11f27a1c
JA
593what the I/O scheduler uses to model scheduling of a process's I/O).
594If processes share the same I/O context,
595they are treated as one by the I/O scheduler.
596As a consequence, they get to share disk time.
597For some I/O schedulers,
598.\" the anticipatory and CFQ scheduler
599if two processes share an I/O context,
600they will be allowed to interleave their disk access.
601If several threads are doing I/O on behalf of the same process
602.RB ( aio_read (3),
603for instance), they should employ
604.BR CLONE_IO
605to get better I/O performance.
606.\" with CFQ and AS.
efeece04 607.IP
11f27a1c
JA
608If the kernel is not configured with the
609.B CONFIG_BLOCK
610option, this flag is a no-op.
611.TP
c5af0674
MK
612.BR CLONE_NEWCGROUP " (since Linux 4.6)"
613Create the process in a new cgroup namespace.
614If this flag is not set, then (as with
615.BR fork (2))
616the process is created in the same cgroup namespaces as the calling process.
efeece04 617.IP
c5af0674 618For further information on cgroup namespaces, see
b9fe4bc3 619.BR cgroup_namespaces (7).
efeece04 620.IP
c5af0674
MK
621Only a privileged process
622.RB ( CAP_SYS_ADMIN )
623can employ
624.BR CLONE_NEWCGROUP .
625.\"
626.TP
8722311b 627.BR CLONE_NEWIPC " (since Linux 2.6.19)"
667417b3
MK
628If
629.B CLONE_NEWIPC
630is set, then create the process in a new IPC namespace.
631If this flag is not set, then (as with
06b30458 632.BR fork (2)),
667417b3
MK
633the process is created in the same IPC namespace as
634the calling process.
efeece04 635.IP
981eda4a
MK
636For further information on IPC namespaces, see
637.BR ipc_namespaces (7).
638.IP
ab5dd83f
MK
639Only a privileged process
640.RB ( CAP_SYS_ADMIN )
641can employ
642.BR CLONE_NEWIPC .
667417b3
MK
643This flag can't be specified in conjunction with
644.BR CLONE_SYSVSEM .
645.TP
163bf178 646.BR CLONE_NEWNET " (since Linux 2.6.24)"
33a0ccb2 647(The implementation of this flag was completed only
9108d867 648by about kernel version 2.6.29.)
efeece04 649.IP
163bf178
MK
650If
651.B CLONE_NEWNET
652is set, then create the process in a new network namespace.
653If this flag is not set, then (as with
57ef8c39 654.BR fork (2))
163bf178
MK
655the process is created in the same network namespace as
656the calling process.
efeece04 657.IP
73680728 658For further information on network namespaces, see
40002795 659.BR network_namespaces (7).
efeece04 660.IP
ab5dd83f
MK
661Only a privileged process
662.RB ( CAP_SYS_ADMIN )
663can employ
664.BR CLONE_NEWNET .
163bf178 665.TP
c10859eb 666.BR CLONE_NEWNS " (since Linux 2.4.19)"
3dd2331c
MK
667If
668.B CLONE_NEWNS
669is set, the cloned child is started in a new mount namespace,
670initialized with a copy of the namespace of the parent.
671If
fea681da 672.B CLONE_NEWNS
3dd2331c 673is not set, the child lives in the same mount
4df2eb09 674namespace as the parent.
efeece04 675.IP
981eda4a
MK
676For further information on mount namespaces, see
677.BR namespaces (7)
678and
679.BR mount_namespaces (7).
680.IP
ab5dd83f
MK
681Only a privileged process
682.RB ( CAP_SYS_ADMIN )
683can employ
684.BR CLONE_NEWNS .
fea681da
MK
685It is not permitted to specify both
686.B CLONE_NEWNS
687and
688.B CLONE_FS
9219d208 689.\" See https://lwn.net/Articles/543273/
5261b0fe 690in the same clone call.
9d005472
MK
691.TP
692.BR CLONE_NEWPID " (since Linux 2.6.24)"
693.\" This explanation draws a lot of details from
694.\" http://lwn.net/Articles/259217/
695.\" Authors: Pavel Emelyanov <xemul@openvz.org>
696.\" and Kir Kolyshkin <kir@openvz.org>
697.\"
698.\" The primary kernel commit is 30e49c263e36341b60b735cbef5ca37912549264
699.\" Author: Pavel Emelyanov <xemul@openvz.org>
700If
701.B CLONE_NEWPID
702is set, then create the process in a new PID namespace.
703If this flag is not set, then (as with
704.BR fork (2))
705the process is created in the same PID namespace as
706the calling process.
efeece04 707.IP
9d005472 708For further information on PID namespaces, see
7e0e902b
MK
709.BR namespaces (7)
710and
39b3f005 711.BR pid_namespaces (7).
efeece04 712.IP
ab5dd83f
MK
713Only a privileged process
714.RB ( CAP_SYS_ADMIN )
715can employ
716.BR CLONE_NEWPID .
9d005472 717This flag can't be specified in conjunction with
f0007192
MK
718.BR CLONE_THREAD
719or
720.BR CLONE_PARENT .
70d21f17 721.TP
06b30458
MK
722.BR CLONE_NEWUSER
723(This flag first became meaningful for
724.BR clone ()
4d2b3ed7
MK
725in Linux 2.6.23,
726the current
11a38815 727.BR clone ()
4d2b3ed7
MK
728semantics were merged in Linux 3.5,
729and the final pieces to make the user namespaces completely usable were
730merged in Linux 3.8.)
efeece04 731.IP
70d21f17
EB
732If
733.B CLONE_NEWUSER
06b30458
MK
734is set, then create the process in a new user namespace.
735If this flag is not set, then (as with
57ef8c39 736.BR fork (2))
70d21f17 737the process is created in the same user namespace as the calling process.
efeece04 738.IP
981eda4a
MK
739For further information on user namespaces, see
740.BR namespaces (7)
741and
742.BR user_namespaces (7).
743.IP
fefbcba8
MK
744Before Linux 3.8, use of
745.BR CLONE_NEWUSER
746required that the caller have three capabilities:
747.BR CAP_SYS_ADMIN ,
748.BR CAP_SETUID ,
749and
750.BR CAP_SETGID .
751.\" Before Linux 2.6.29, it appears that only CAP_SYS_ADMIN was needed
06b30458 752Starting with Linux 3.8,
9d005472 753no privileges are needed to create a user namespace.
efeece04 754.IP
5e72cf7d
MK
755This flag can't be specified in conjunction with
756.BR CLONE_THREAD
757or
758.BR CLONE_PARENT .
759For security reasons,
760.\" commit e66eded8309ebf679d3d3c1f5820d1f2ca332c71
761.\" https://lwn.net/Articles/543273/
762.\" The fix actually went into 3.9 and into 3.8.3. However, user namespaces
763.\" were, for practical purposes, unusable in earlier 3.8.x because of the
ab3311aa 764.\" various filesystems that didn't support userns.
f0007192
MK
765.BR CLONE_NEWUSER
766cannot be specified in conjunction with
5e72cf7d 767.BR CLONE_FS .
82ee147a 768.TP
43ce9dda
MK
769.BR CLONE_NEWUTS " (since Linux 2.6.19)"
770If
771.B CLONE_NEWUTS
e1b11906
MK
772is set, then create the process in a new UTS namespace,
773whose identifiers are initialized by duplicating the identifiers
774from the UTS namespace of the calling process.
43ce9dda 775If this flag is not set, then (as with
57ef8c39 776.BR fork (2))
43ce9dda
MK
777the process is created in the same UTS namespace as
778the calling process.
efeece04 779.IP
981eda4a
MK
780For further information on UTS namespaces, see
781.BR uts_namespaces (7).
782.IP
ab5dd83f
MK
783Only a privileged process
784.RB ( CAP_SYS_ADMIN )
785can employ
786.BR CLONE_NEWUTS .
43ce9dda 787.TP
f5dbc7c8
MK
788.BR CLONE_PARENT " (since Linux 2.3.12)"
789If
790.B CLONE_PARENT
791is set, then the parent of the new child (as returned by
792.BR getppid (2))
793will be the same as that of the calling process.
efeece04 794.IP
f5dbc7c8
MK
795If
796.B CLONE_PARENT
797is not set, then (as with
798.BR fork (2))
799the child's parent is the calling process.
efeece04 800.IP
f5dbc7c8
MK
801Note that it is the parent process, as returned by
802.BR getppid (2),
803which is signaled when the child terminates, so that
804if
805.B CLONE_PARENT
806is set, then the parent of the calling process, rather than the
807calling process itself, will be signaled.
a17b9d28 808.IP
4269a6ab 809The
a17b9d28 810.B CLONE_PARENT
4269a6ab
MK
811flag can't be used in clone calls by the
812global init process (PID 1 in the initial PID namespace)
813and init processes in other PID namespaces.
814This restriction prevents the creation of multi-rooted process trees
815as well as the creation of unreapable zombies in the initial PID namespace.
f5dbc7c8
MK
816.TP
817.BR CLONE_PARENT_SETTID " (since Linux 2.5.49)"
e2bf1234 818Store the child thread ID at the location pointed to by
81c2368f 819.I parent_tid
faa0e55a
MK
820.RB ( clone ())
821or
d5d482ec 822.I cl_args.parent_tid
faa0e55a 823.RB ( clone3 ())
8ef021ea 824in the parent's memory.
f5dbc7c8
MK
825(In Linux 2.5.32-2.5.48 there was a flag
826.B CLONE_SETTID
827that did this.)
5261b0fe 828The store operation completes before the clone call
b5da2f91 829returns control to user space.
f5dbc7c8 830.TP
1c173eb3 831.BR CLONE_PID " (Linux 2.0 to 2.5.15)"
f5dbc7c8
MK
832If
833.B CLONE_PID
834is set, the child process is created with the same process ID as
835the calling process.
836This is good for hacking the system, but otherwise
837of not much use.
1c173eb3 838From Linux 2.3.21 onward, this flag could be
f5dbc7c8 839specified only by the system boot process (PID 0).
1c173eb3 840The flag disappeared completely from the kernel sources in Linux 2.5.16.
f5d5180f 841Subsequently, the kernel silently ignored this bit if it was specified in the
16853a31
MK
842.IR flags
843mask.
f5d5180f
MK
844Much later, the same bit was recycled for use as the
845.B CLONE_PIDFD
846flag.
f5dbc7c8 847.TP
9f938981 848.BR CLONE_PIDFD " (since Linux 5.2)"
4e98b074 849.\" commit b3e5838252665ee4cfa76b82bdf1198dca81e5be
faa0e55a
MK
850If this flag is specified,
851a PID file descriptor referring to the child process is allocated
852and placed at a specified location in the parent's memory.
b4ebffb2 853The close-on-exec flag is set on this new file descriptor.
34a975f8
MK
854PID file descriptors can be used for the purposes described in
855.BR pidfd_open (2).
faa0e55a
MK
856.RS
857.IP * 3
858When using
859.BR clone3 (),
860the PID file descriptor is placed at the location pointed to by
861.IR cl_args.pidfd .
862.IP *
863When using
864.BR clone (),
865the PID file descriptor is placed at the location pointed to by
866.IR parent_tid .
9f938981 867Since the
81c2368f 868.I parent_tid
b97cc7ae 869argument is used to return the PID file descriptor,
9f938981
CB
870.B CLONE_PIDFD
871cannot be used with
faa0e55a
MK
872.B CLONE_PARENT_SETTID
873when calling
874.BR clone ().
875.RE
9f938981
CB
876.IP
877It is currently not possible to use this flag together with
878.B CLONE_THREAD.
b97cc7ae 879This means that the process identified by the PID file descriptor
f6183e5b 880will always be a thread group leader.
9f938981 881.IP
baa435c6 882If the obsolete
9f938981 883.B CLONE_DETACHED
baa435c6
MK
884flag is specified alongside
885.BR CLONE_PIDFD
886when calling
887.BR clone (),
4e98b074 888an error is returned.
baa435c6
MK
889An error also results if
890.B CLONE_DETACHED
891is specified when calling
892.BR clone3 ().
893This error behavior ensures that the bit corresponding to
894.BR CLONE_DETACHED
895can be reused for further PID file descriptor features in the future.
9f938981 896.TP
1603d6a1 897.BR CLONE_PTRACE " (since Linux 2.2)"
f5dbc7c8
MK
898If
899.B CLONE_PTRACE
900is specified, and the calling process is being traced,
901then trace the child also (see
902.BR ptrace (2)).
903.TP
904.BR CLONE_SETTLS " (since Linux 2.5.32)"
dd6d3d2e 905The TLS (Thread Local Storage) descriptor is set to
81c2368f 906.IR tls .
efeece04 907.IP
dd6d3d2e 908The interpretation of
81c2368f 909.I tls
dd6d3d2e
KF
910and the resulting effect is architecture dependent.
911On x86,
81c2368f 912.I tls
dd6d3d2e 913is interpreted as a
2551f801 914.IR "struct user_desc\ *"
35bf8cb4 915(see
dd6d3d2e 916.BR set_thread_area (2)).
9ea5bc66 917On x86-64 it is the new value to be set for the %fs base register
35bf8cb4 918(see the
2551f801 919.B ARCH_SET_FS
dd6d3d2e
KF
920argument to
921.BR arch_prctl (2)).
922On architectures with a dedicated TLS register, it is the new value
923of that register.
f5d5180f
MK
924.IP
925Use of this flag requires detailed knowledge and generally it
926should not be used except in libraries implementing threading.
f5dbc7c8 927.TP
1603d6a1 928.BR CLONE_SIGHAND " (since Linux 2.0)"
fea681da
MK
929If
930.B CLONE_SIGHAND
314c8ff4 931is set, the calling process and the child process share the same table of
c13182ef
MK
932signal handlers.
933If the calling process or child process calls
fea681da 934.BR sigaction (2)
c13182ef
MK
935to change the behavior associated with a signal, the behavior is
936changed in the other process as well.
937However, the calling process and child
fea681da 938processes still have distinct signal masks and sets of pending
c13182ef 939signals.
4ba17a6d 940So, one of them may block or unblock signals using
fea681da
MK
941.BR sigprocmask (2)
942without affecting the other process.
efeece04 943.IP
fea681da
MK
944If
945.B CLONE_SIGHAND
946is not set, the child process inherits a copy of the signal handlers
5261b0fe 947of the calling process at the time of the clone call.
c13182ef 948Calls to
fea681da
MK
949.BR sigaction (2)
950performed later by one of the processes have no effect on the other
951process.
efeece04 952.IP
d6bec36e
MK
953Since Linux 2.6.0,
954.\" Precisely: Linux 2.6.0-test6
16853a31 955the
29546c24 956.I flags
16853a31 957mask must also include
29546c24
MK
958.B CLONE_VM
959if
960.B CLONE_SIGHAND
961is specified
fea681da 962.TP
d6bec36e
MK
963.BR CLONE_STOPPED " (since Linux 2.6.0)"
964.\" Precisely: Linux 2.6.0-test2
a69b6bda
MK
965If
966.B CLONE_STOPPED
967is set, then the child is initially stopped (as though it was sent a
968.B SIGSTOP
969signal), and must be resumed by sending it a
970.B SIGCONT
971signal.
efeece04 972.IP
a60450a9
MK
973This flag was
974.I deprecated
975from Linux 2.6.25 onward,
976and was
977.I removed
28b44abc
MK
978altogether in Linux 2.6.38.
979Since then, the kernel silently ignores it without error.
a5a061ee 980.\" glibc 2.8 removed this defn from bits/sched.h
c5af0674
MK
981Starting with Linux 4.6, the same bit was reused for the
982.BR CLONE_NEWCGROUP
983flag.
a69b6bda 984.TP
f5dbc7c8 985.BR CLONE_SYSVSEM " (since Linux 2.5.10)"
fea681da 986If
f5dbc7c8
MK
987.B CLONE_SYSVSEM
988is set, then the child and the calling process share
5ada4b94
MK
989a single list of System V semaphore adjustment
990.RI ( semadj )
991values (see
f5dbc7c8 992.BR semop (2)).
5ada4b94
MK
993In this case, the shared list accumulates
994.I semadj
995values across all processes sharing the list,
996and semaphore adjustments are performed only when the last process
997that is sharing the list terminates (or ceases sharing the list using
998.BR unshare (2)).
f5d401dd 999If this flag is not set, then the child has a separate
5ada4b94
MK
1000.I semadj
1001list that is initially empty.
fea681da 1002.TP
d6bec36e
MK
1003.BR CLONE_THREAD " (since Linux 2.4.0)"
1004.\" Precisely: Linux 2.6.0-test8
fea681da
MK
1005If
1006.B CLONE_THREAD
1007is set, the child is placed in the same thread group as the calling process.
fd8a5be4
MK
1008To make the remainder of the discussion of
1009.B CLONE_THREAD
1010more readable, the term "thread" is used to refer to the
1011processes within a thread group.
efeece04 1012.IP
fd8a5be4
MK
1013Thread groups were a feature added in Linux 2.4 to support the
1014POSIX threads notion of a set of threads that share a single PID.
1015Internally, this shared PID is the so-called
1016thread group identifier (TGID) for the thread group.
c13182ef 1017Since Linux 2.4, calls to
fea681da 1018.BR getpid (2)
fd8a5be4 1019return the TGID of the caller.
efeece04 1020.IP
fd8a5be4
MK
1021The threads within a group can be distinguished by their (system-wide)
1022unique thread IDs (TID).
1023A new thread's TID is available as the function result
5261b0fe 1024returned to the caller,
fd8a5be4
MK
1025and a thread can obtain
1026its own TID using
1027.BR gettid (2).
efeece04 1028.IP
5261b0fe 1029When a clone call is made without specifying
fd8a5be4
MK
1030.BR CLONE_THREAD ,
1031then the resulting thread is placed in a new thread group
1032whose TGID is the same as the thread's TID.
1033This thread is the
1034.I leader
1035of the new thread group.
efeece04 1036.IP
fd8a5be4
MK
1037A new thread created with
1038.B CLONE_THREAD
5261b0fe 1039has the same parent process as the process that made the clone call
c13182ef 1040(i.e., like
fd8a5be4
MK
1041.BR CLONE_PARENT ),
1042so that calls to
1043.BR getppid (2)
1044return the same value for all of the threads in a thread group.
1045When a
c13182ef 1046.B CLONE_THREAD
5261b0fe 1047thread terminates, the thread that created it is not sent a
fd8a5be4
MK
1048.B SIGCHLD
1049(or other termination) signal;
1050nor can the status of such a thread be obtained
1051using
1052.BR wait (2).
1053(The thread is said to be
1054.IR detached .)
efeece04 1055.IP
e2fbf61d
MK
1056After all of the threads in a thread group terminate
1057the parent process of the thread group is sent a
fd8a5be4
MK
1058.B SIGCHLD
1059(or other termination) signal.
efeece04 1060.IP
fd8a5be4
MK
1061If any of the threads in a thread group performs an
1062.BR execve (2),
1063then all threads other than the thread group leader are terminated,
1064and the new program is executed in the thread group leader.
efeece04 1065.IP
f7110f60
MK
1066If one of the threads in a thread group creates a child using
1067.BR fork (2),
1068then any thread in the group can
1069.BR wait (2)
1070for that child.
efeece04 1071.IP
16853a31 1072Since Linux 2.5.35, the
fd8a5be4 1073.I flags
16853a31 1074mask must also include
fd8a5be4
MK
1075.B CLONE_SIGHAND
1076if
1077.B CLONE_THREAD
6fd69f33 1078is specified
d6bec36e
MK
1079(and note that, since Linux 2.6.0,
1080.\" Precisely: Linux 2.6.0-test6
6fd69f33
MK
1081.BR CLONE_SIGHAND
1082also requires
1083.BR CLONE_VM
1084to be included).
efeece04 1085.IP
e2fbf61d
MK
1086Signal dispositions and actions are process-wide:
1087if an unhandled signal is delivered to a thread, then
1088it will affect (terminate, stop, continue, be ignored in)
1089all members of the thread group.
efeece04 1090.IP
99408a60 1091Each thread has its own signal mask, as set by
f957eebd
MK
1092.BR sigprocmask (2).
1093.IP
1094A signal may be process-directed or thread-directed.
1095A process-directed signal is targeted at a thread group (i.e., a TGID),
1096and is delivered to an arbitrarily selected thread from among those
1097that are not blocking the signal.
ed4f87f0 1098A signal may be process-directed because it was generated by the kernel
f957eebd
MK
1099for reasons other than a hardware exception, or because it was sent using
1100.BR kill (2)
1101or
1102.BR sigqueue (3).
1103A thread-directed signal is targeted at (i.e., delivered to)
1104a specific thread.
1105A signal may be thread directed because it was sent using
1106.BR tgkill (2)
1107or
1108.BR pthread_sigqueue (3),
1109or because the thread executed a machine language instruction that triggered
1110a hardware exception
1111(e.g., invalid memory access triggering
1112.BR SIGSEGV
1113or a floating-point exception triggering
1114.BR SIGFPE ).
1115.IP
99408a60
MK
1116A call to
1117.BR sigpending (2)
f957eebd
MK
1118returns a signal set that is the union of the pending process-directed
1119signals and the signals that are pending for the calling thread.
efeece04 1120.IP
475c2753 1121If a process-directed signal is delivered to a thread group,
e2fbf61d
MK
1122and the thread group has installed a handler for the signal, then
1123the handler will be invoked in exactly one, arbitrarily selected
1124member of the thread group that has not blocked the signal.
c13182ef 1125If multiple threads in a group are waiting to accept the same signal using
e2fbf61d
MK
1126.BR sigwaitinfo (2),
1127the kernel will arbitrarily select one of these threads
475c2753 1128to receive the signal.
a69b6bda 1129.TP
f5dbc7c8 1130.BR CLONE_UNTRACED " (since Linux 2.5.46)"
a69b6bda 1131If
f5dbc7c8
MK
1132.B CLONE_UNTRACED
1133is specified, then a tracing process cannot force
1134.B CLONE_PTRACE
1135on this child process.
fea681da 1136.TP
1603d6a1 1137.BR CLONE_VFORK " (since Linux 2.2)"
f5dbc7c8
MK
1138If
1139.B CLONE_VFORK
1140is set, the execution of the calling process is suspended
1141until the child releases its virtual memory
1142resources via a call to
1143.BR execve (2)
1144or
1145.BR _exit (2)
1146(as with
1147.BR vfork (2)).
efeece04 1148.IP
f5dbc7c8
MK
1149If
1150.B CLONE_VFORK
4b4a853a 1151is not set, then both the calling process and the child are schedulable
f5dbc7c8
MK
1152after the call, and an application should not rely on execution occurring
1153in any particular order.
fea681da 1154.TP
1603d6a1 1155.BR CLONE_VM " (since Linux 2.0)"
f5dbc7c8
MK
1156If
1157.B CLONE_VM
1158is set, the calling process and the child process run in the same memory
1159space.
1160In particular, memory writes performed by the calling process
1161or by the child process are also visible in the other process.
1162Moreover, any memory mapping or unmapping performed with
1163.BR mmap (2)
1164or
1165.BR munmap (2)
1166by the child or calling process also affects the other process.
efeece04 1167.IP
f5dbc7c8
MK
1168If
1169.B CLONE_VM
1170is not set, the child process runs in a separate copy of the memory
5261b0fe 1171space of the calling process at the time of the clone call.
f5dbc7c8
MK
1172Memory writes or file mappings/unmappings performed by one of the
1173processes do not affect the other, as with
1174.BR fork (2).
1874193e 1175.SH NOTES
b7cf324f 1176.PP
faa0e55a 1177One use of these systems calls
b7cf324f
MK
1178is to implement threads: multiple flows of control in a program that
1179run concurrently in a shared address space.
1180.PP
faa0e55a 1181Glibc does not provide a wrapper for
5261b0fe 1182.BR clone3 ();
faa0e55a
MK
1183call it using
1184.BR syscall (2).
1185.PP
1c6ebc4b
MK
1186Note that the glibc
1187.BR clone ()
1188wrapper function makes some changes
1189in the memory pointed to by
81c2368f 1190.I stack
1c6ebc4b
MK
1191(changes required to set the stack up correctly for the child)
1192.I before
1193invoking the
1194.BR clone ()
1195system call.
1196So, in cases where
1197.BR clone ()
1198is used to recursively create children,
1199do not use the buffer employed for the parent's stack
1200as the stack of the child.
1201.\"
0722a578 1202.SS C library/kernel differences
e585064b
MK
1203The raw
1204.BR clone ()
fea681da
MK
1205system call corresponds more closely to
1206.BR fork (2)
1207in that execution in the child continues from the point of the
c13182ef 1208call.
5add3af3
MK
1209As such, the
1210.I fn
c13182ef 1211and
5add3af3
MK
1212.I arg
1213arguments of the
1214.BR clone ()
1215wrapper function are omitted.
161fce30 1216.PP
f5d5180f 1217In contrast to the glibc wrapper, the raw
d35f5c34 1218.BR clone ()
f5d5180f 1219system call accepts NULL as a
81c2368f 1220.I stack
f5d5180f
MK
1221argument (and
1222.BR clone3 ()
1223likewise allows
1224.I cl_args.stack
1225to be NULL).
1226In this case, the child uses a duplicate of the parent's stack.
b219e68c
MK
1227(Copy-on-write semantics ensure that the child gets separate copies
1228of stack pages when either process modifies the stack.)
1229In this case, for correct operation, the
1230.B CLONE_VM
1231option should not be specified.
d35f5c34
MK
1232(If the child
1233.I shares
1234the parent's memory because of the use of the
1235.BR CLONE_VM
b219e68c
MK
1236flag,
1237then no copy-on-write duplication occurs and chaos is likely to result.)
d35f5c34 1238.PP
161fce30
MK
1239The order of the arguments also differs in the raw system call,
1240and there are variations in the arguments across architectures,
1241as detailed in the following paragraphs.
efeece04 1242.PP
2a15a76b 1243The raw system call interface on x86-64 and some other architectures
f5d5180f 1244(including sh, tile, and alpha) is:
efeece04 1245.PP
5add3af3 1246.in +4
b76974c1 1247.EX
81c2368f
MK
1248.BI "long clone(unsigned long " flags ", void *" stack ,
1249.BI " int *" parent_tid ", int *" child_tid ,
1250.BI " unsigned long " tls );
b76974c1 1251.EE
2a15a76b 1252.in
efeece04 1253.PP
2a15a76b
MK
1254On x86-32, and several other common architectures
1255(including score, ARM, ARM 64, PA-RISC, arc, Power PC, xtensa,
1256and MIPS),
1257.\" CONFIG_CLONE_BACKWARDS
1258the order of the last two arguments is reversed:
efeece04 1259.PP
2a15a76b 1260.in +4
b76974c1 1261.EX
81c2368f
MK
1262.BI "long clone(unsigned long " flags ", void *" stack ,
1263.BI " int *" parent_tid ", unsigned long " tls ,
1264.BI " int *" child_tid );
b76974c1 1265.EE
2a15a76b 1266.in
efeece04 1267.PP
2a15a76b
MK
1268On the cris and s390 architectures,
1269.\" CONFIG_CLONE_BACKWARDS2
1270the order of the first two arguments is reversed:
efeece04 1271.PP
2a15a76b 1272.in +4
b76974c1 1273.EX
81c2368f
MK
1274.BI "long clone(void *" stack ", unsigned long " flags ,
1275.BI " int *" parent_tid ", int *" child_tid ,
1276.BI " unsigned long " tls );
b76974c1 1277.EE
2a15a76b 1278.in
efeece04 1279.PP
2a15a76b
MK
1280On the microblaze architecture,
1281.\" CONFIG_CLONE_BACKWARDS3
1282an additional argument is supplied:
efeece04 1283.PP
2a15a76b 1284.in +4
b76974c1 1285.EX
81c2368f 1286.BI "long clone(unsigned long " flags ", void *" stack ,
2a15a76b 1287.BI " int " stack_size , "\fR /* Size of stack */"
81c2368f
MK
1288.BI " int *" parent_tid ", int *" child_tid ,
1289.BI " unsigned long " tls );
b76974c1 1290.EE
5add3af3 1291.in
2a15a76b 1292.\"
251113d0 1293.SS blackfin, m68k, and sparc
2a15a76b
MK
1294.\" Mike Frysinger noted in a 2013 mail:
1295.\" these arches don't define __ARCH_WANT_SYS_CLONE:
1296.\" blackfin ia64 m68k sparc
251113d0 1297The argument-passing conventions on
04346be5 1298blackfin, m68k, and sparc are different from the descriptions above.
251113d0 1299For details, see the kernel (and glibc) source.
574c92b6 1300.SS ia64
097a1f3b 1301On ia64, a different interface is used:
7a346077 1302.PP
8016cc90
ES
1303.in +4
1304.EX
097a1f3b 1305.BI "int __clone2(int (*" "fn" ")(void *), "
81c2368f 1306.BI " void *" stack_base ", size_t " stack_size ,
097a1f3b 1307.BI " int " flags ", void *" "arg" ", ... "
81c2368f
MK
1308.BI " /* pid_t *" parent_tid ", struct user_desc *" tls ,
1309.BI " pid_t *" child_tid " */ );"
8016cc90
ES
1310.EE
1311.in
097a1f3b 1312.PP
9b9c895c
MK
1313The prototype shown above is for the glibc wrapper function;
1314for the system call itself,
1315the prototype can be described as follows (it is identical to the
8016cc90
ES
1316.BR clone ()
1317prototype on microblaze):
1318.PP
1319.in +4
1320.EX
81c2368f 1321.BI "long clone2(unsigned long " flags ", void *" stack_base ,
8016cc90 1322.BI " int " stack_size , "\fR /* Size of stack */"
81c2368f 1323.BI " int *" parent_tid ", int *" child_tid ,
8016cc90
ES
1324.BI " unsigned long " tls );
1325.EE
1326.in
097a1f3b
MK
1327.PP
1328.BR __clone2 ()
1329operates in the same way as
1330.BR clone (),
1331except that
81c2368f 1332.I stack_base
097a1f3b
MK
1333points to the lowest address of the child's stack area,
1334and
1335.I stack_size
1336specifies the size of the stack pointed to by
81c2368f 1337.IR stack_base .
5add3af3 1338.SS Linux 2.4 and earlier
577f9b62
MK
1339In Linux 2.4 and earlier,
1340.BR clone ()
1341does not take arguments
81c2368f 1342.IR parent_tid ,
577f9b62
MK
1343.IR tls ,
1344and
81c2368f 1345.IR child_tid .
47297adb 1346.SH RETURN VALUE
0bfa087b
MK
1347.\" gettid(2) returns current->pid;
1348.\" getpid(2) returns current->tgid;
fea681da 1349On success, the thread ID of the child process is returned
c13182ef 1350in the caller's thread of execution.
84811e86 1351On failure, \-1 is returned
fea681da
MK
1352in the caller's context, no child process will be created, and
1353.I errno
1354will be set appropriately.
fea681da
MK
1355.SH ERRORS
1356.TP
1357.B EAGAIN
e1b6e186
MK
1358Too many processes are already running; see
1359.BR fork (2).
fea681da 1360.TP
bf031aaa 1361.BR EEXIST " (" clone3 "() only)"
ee8bb310 1362One (or more) of the PIDs specified in
bf031aaa
AR
1363.I set_tid
1364already exists in the corresponding PID namespace.
1365.TP
fea681da 1366.B EINVAL
27f14b44
MK
1367Both
1368.B CLONE_SIGHAND
1369and
1370.B CLONE_CLEAR_SIGHAND
1371were specified in the
1372.I flags
1373mask.
1374.TP
1375.B EINVAL
fea681da 1376.B CLONE_SIGHAND
16853a31
MK
1377was specified in the
1378.I flags
1379mask, but
fea681da 1380.B CLONE_VM
2e8a7fb3 1381was not.
d6bec36e
MK
1382(Since Linux 2.6.0.)
1383.\" Precisely: Linux 2.6.0-test6
fea681da
MK
1384.TP
1385.B EINVAL
1386.B CLONE_THREAD
16853a31
MK
1387was specified in the
1388.I flags
1389mask, but
fea681da 1390.B CLONE_SIGHAND
6387216b
MK
1391was not.
1392(Since Linux 2.5.35.)
29546c24
MK
1393.\" .TP
1394.\" .B EINVAL
1395.\" Precisely one of
1396.\" .B CLONE_DETACHED
1397.\" and
1398.\" .B CLONE_THREAD
6387216b
MK
1399.\" was specified.
1400.\" (Since Linux 2.6.0-test6.)
fea681da
MK
1401.TP
1402.B EINVAL
d6868c69 1403.B CLONE_THREAD
16853a31
MK
1404was specified in the
1405.I flags
1406mask, but the current process previously called
d6868c69
JH
1407.BR unshare (2)
1408with the
1409.B CLONE_NEWPID
1410flag or used
1411.BR setns (2)
1412to reassociate itself with a PID namespace.
1413.TP
1414.B EINVAL
d34e5645 1415.\" commit e66eded8309ebf679d3d3c1f5820d1f2ca332c71
fea681da
MK
1416Both
1417.B CLONE_FS
1418and
1419.B CLONE_NEWNS
16853a31
MK
1420were specified in the
1421.IR flags
1422mask.
fea681da 1423.TP
d34e5645
MK
1424.BR EINVAL " (since Linux 3.9)"
1425Both
1426.B CLONE_NEWUSER
1427and
1428.B CLONE_FS
16853a31
MK
1429were specified in the
1430.IR flags
1431mask.
d34e5645 1432.TP
fea681da 1433.B EINVAL
82ee147a 1434Both
667417b3
MK
1435.B CLONE_NEWIPC
1436and
1437.B CLONE_SYSVSEM
16853a31
MK
1438were specified in the
1439.IR flags
1440mask.
667417b3
MK
1441.TP
1442.B EINVAL
f0007192 1443One (or both) of
82ee147a 1444.BR CLONE_NEWPID
f0007192
MK
1445or
1446.BR CLONE_NEWUSER
1447and one (or both) of
82ee147a 1448.BR CLONE_THREAD
f0007192
MK
1449or
1450.BR CLONE_PARENT
16853a31
MK
1451were specified in the
1452.IR flags
1453mask.
82ee147a 1454.TP
be479fdf
MK
1455.BR EINVAL " (since Linux 2.6.32)"
1456.\" commit 123be07b0b399670a7cc3d82fef0cb4f93ef885c
1457.BR CLONE_PARENT
1458was specified, and the caller is an init process.
1459.TP
82ee147a 1460.B EINVAL
d4748fad 1461Returned by the glibc
edcc65ff 1462.BR clone ()
d4748fad
MK
1463wrapper function when
1464.IR fn
1465or
81c2368f 1466.IR stack
d4748fad 1467is specified as NULL.
fea681da 1468.TP
28cad2c1 1469.B EINVAL
667417b3 1470.BR CLONE_NEWIPC
16853a31
MK
1471was specified in the
1472.IR flags
1473mask,
667417b3
MK
1474but the kernel was not configured with the
1475.B CONFIG_SYSVIPC
1476and
1477.BR CONFIG_IPC_NS
1478options.
1479.TP
1480.B EINVAL
163bf178 1481.BR CLONE_NEWNET
16853a31
MK
1482was specified in the
1483.IR flags
1484mask,
163bf178
MK
1485but the kernel was not configured with the
1486.B CONFIG_NET_NS
1487option.
1488.TP
1489.B EINVAL
28cad2c1 1490.BR CLONE_NEWPID
16853a31
MK
1491was specified in the
1492.IR flags
1493mask,
28cad2c1
MK
1494but the kernel was not configured with the
1495.B CONFIG_PID_NS
1496option.
1497.TP
43ce9dda 1498.B EINVAL
231d0bbe 1499.BR CLONE_NEWUSER
16853a31
MK
1500was specified in the
1501.IR flags
1502mask,
231d0bbe
MK
1503but the kernel was not configured with the
1504.B CONFIG_USER_NS
1505option.
1506.TP
1507.B EINVAL
43ce9dda 1508.BR CLONE_NEWUTS
16853a31
MK
1509was specified in the
1510.IR flags
1511mask,
43ce9dda 1512but the kernel was not configured with the
832fe8ea 1513.B CONFIG_UTS_NS
43ce9dda
MK
1514option.
1515.TP
c550a897 1516.B EINVAL
81c2368f 1517.I stack
c550a897
MK
1518is not aligned to a suitable boundary for this architecture.
1519For example, on aarch64,
81c2368f 1520.I stack
c550a897
MK
1521must be a multiple of 16.
1522.TP
bc03b116 1523.BR EINVAL " (" clone3 "() only)"
baa435c6
MK
1524.B CLONE_DETACHED
1525was specified in the
1526.I flags
1527mask.
1528.TP
bc03b116 1529.BR EINVAL " (" clone "() only)"
9f938981
CB
1530.B CLONE_PIDFD
1531was specified together with
16853a31
MK
1532.B CLONE_DETACHED
1533in the
1534.I flags
1535mask.
9f938981
CB
1536.TP
1537.B EINVAL
1538.B CLONE_PIDFD
1539was specified together with
16853a31
MK
1540.B CLONE_THREAD
1541in the
1542.I flags
1543mask.
9f938981 1544.TP
faa0e55a 1545.BR "EINVAL " "(" clone "() only)"
9f938981
CB
1546.B CLONE_PIDFD
1547was specified together with
16853a31
MK
1548.B CLONE_PARENT_SETTID
1549in the
1550.I flags
1551mask.
9f938981 1552.TP
bf031aaa
AR
1553.BR EINVAL " (" clone3 "() only)"
1554.I set_tid_size
ee8bb310 1555is greater than the number of nested PID namespaces.
bf031aaa
AR
1556.TP
1557.BR EINVAL " (" clone3 "() only)"
2a2b2a5d 1558One of the PIDs specified in
bf031aaa 1559.I set_tid
2a2b2a5d 1560was an invalid.
bf031aaa 1561.TP
ba9ae75d
MK
1562.BR EINVAL " (AArch64 only, Linux 4.6 and earlier)"
1563.I stack
1564was not aligned to a 126-bit boundary.
1565.TP
fea681da
MK
1566.B ENOMEM
1567Cannot allocate sufficient memory to allocate a task structure for the
1568child, or to copy those parts of the caller's context that need to be
1569copied.
1570.TP
b20e22ae
MK
1571.BR ENOSPC " (since Linux 3.7)"
1572.\" commit f2302505775fd13ba93f034206f1e2a587017929
1573.B CLONE_NEWPID
16853a31
MK
1574was specified in the
1575.I flags
1576mask,
b20e22ae
MK
1577but the limit on the nesting depth of PID namespaces
1578would have been exceeded; see
1579.BR pid_namespaces (7).
1580.TP
b5742ecc
MK
1581.BR ENOSPC " (since Linux 4.9; beforehand " EUSERS )
1582.B CLONE_NEWUSER
16853a31
MK
1583was specified in the
1584.IR flags
1585mask, and the call would cause the limit on the number of
b5742ecc
MK
1586nested user namespaces to be exceeded.
1587See
1588.BR user_namespaces (7).
efeece04 1589.IP
b5742ecc
MK
1590From Linux 3.11 to Linux 4.8, the error diagnosed in this case was
1591.BR EUSERS .
1592.TP
2f7a331e 1593.BR ENOSPC " (since Linux 4.9)"
16853a31 1594One of the values in the
2f7a331e 1595.I flags
16853a31 1596mask specified the creation of a new user namespace,
2f7a331e
MK
1597but doing so would have caused the limit defined by the corresponding file in
1598.IR /proc/sys/user
1599to be exceeded.
1600For further details, see
1601.BR namespaces (7).
1602.TP
fea681da 1603.B EPERM
aa825b59 1604.BR CLONE_NEWCGROUP ,
667417b3 1605.BR CLONE_NEWIPC ,
163bf178 1606.BR CLONE_NEWNET ,
43ce9dda
MK
1607.BR CLONE_NEWNS ,
1608.BR CLONE_NEWPID ,
82ee147a 1609or
43ce9dda 1610.BR CLONE_NEWUTS
00b08db3 1611was specified by an unprivileged process (process without \fBCAP_SYS_ADMIN\fP).
fea681da
MK
1612.TP
1613.B EPERM
1614.B CLONE_PID
1615was specified by a process other than process 0.
1c173eb3 1616(This error occurs only on Linux 2.5.15 and earlier.)
365d292a
MK
1617.TP
1618.B EPERM
1619.BR CLONE_NEWUSER
16853a31
MK
1620was specified in the
1621.IR flags
1622mask,
365d292a
MK
1623but either the effective user ID or the effective group ID of the caller
1624does not have a mapping in the parent namespace (see
f58fb24f 1625.BR user_namespaces (7)).
6fd119e7 1626.TP
ac007938
MK
1627.BR EPERM " (since Linux 3.9)"
1628.\" commit 3151527ee007b73a0ebd296010f1c0454a919c7d
11a38815 1629.B CLONE_NEWUSER
16853a31 1630was specified in the
ac007938 1631.I flags
16853a31 1632mask and the caller is in a chroot environment
ac007938
MK
1633.\" FIXME What is the rationale for this restriction?
1634(i.e., the caller's root directory does not match the root directory
1635of the mount namespace in which it resides).
1636.TP
bf031aaa
AR
1637.BR EPERM " (" clone3 "() only)"
1638.I set_tid_size
1639was greater than zero, and the caller lacks the
1640.B CAP_SYS_ADMIN
1641capability in one or more of the user namespaces that own the
1642corresponding PID namespaces.
1643.TP
6717ee86
MK
1644.BR ERESTARTNOINTR " (since Linux 2.6.17)"
1645.\" commit 4a2c7a7837da1b91468e50426066d988050e4d56
1646System call was interrupted by a signal and will be restarted.
1647(This can be seen only during a trace.)
1648.TP
b5742ecc 1649.BR EUSERS " (Linux 3.11 to Linux 4.8)"
6fd119e7 1650.B CLONE_NEWUSER
16853a31
MK
1651was specified in the
1652.IR flags
1653mask,
b5742ecc
MK
1654and the limit on the number of nested user namespaces would be exceeded.
1655See the discussion of the
1656.BR ENOSPC
1657error above.
faa0e55a
MK
1658.SH VERSIONS
1659The
1660.BR clone3 ()
1661system call first appeared in Linux 5.3.
92b72224
MK
1662.\" There is no entry for
1663.\" .BR clone ()
1664.\" in libc5.
1665.\" glibc2 provides
1666.\" .BR clone ()
1667.\" as described in this manual page.
47297adb 1668.SH CONFORMING TO
faa0e55a
MK
1669These system calls
1670are Linux-specific and should not be used in programs
a1d5f77c 1671intended to be portable.
fea681da 1672.SH NOTES
79bdcc4a
MK
1673The
1674.BR kcmp (2)
1675system call can be used to test whether two processes share various
49dba87f 1676resources such as a file descriptor table,
79bdcc4a 1677System V semaphore undo operations, or a virtual address space.
efeece04
MK
1678.PP
1679.PP
c471c363
MK
1680Handlers registered using
1681.BR pthread_atfork (3)
5261b0fe 1682are not executed during a clone call.
efeece04 1683.PP
ca8b1e32 1684In the Linux 2.4.x series,
fd8a5be4
MK
1685.B CLONE_THREAD
1686generally does not make the parent of the new thread the same
1687as the parent of the calling process.
1688However, for kernel versions 2.4.7 to 2.4.18 the
1689.B CLONE_THREAD
1690flag implied the
c13182ef 1691.B CLONE_PARENT
ca8b1e32 1692flag (as in Linux 2.6.0 and later).
efeece04 1693.PP
34ccb744 1694On i386,
a5a997ca
MK
1695.BR clone ()
1696should not be called through vsyscall, but directly through
1697.IR "int $0x80" .
31830ef0 1698.SH BUGS
abcf3b1d
MK
1699GNU C library versions 2.3.4 up to and including 2.24
1700contained a wrapper function for
0bfa087b 1701.BR getpid (2)
abcf3b1d
MK
1702that performed caching of PIDs.
1703This caching relied on support in the glibc wrapper for
c60237c9 1704.BR clone (),
abcf3b1d
MK
1705but limitations in the implementation
1706meant that the cache was not up to date in some circumstances.
c60237c9 1707In particular,
abcf3b1d 1708if a signal was delivered to the child immediately after the
c60237c9
MK
1709.BR clone ()
1710call, then a call to
0b80cf56 1711.BR getpid (2)
abcf3b1d 1712in a handler for the signal could return the PID
c60237c9 1713of the calling process ("the parent"),
abcf3b1d 1714if the clone wrapper had not yet had a chance to update the PID
c60237c9
MK
1715cache in the child.
1716(This discussion ignores the case where the child was created using
9291ce36 1717.BR CLONE_THREAD ,
c60237c9 1718when
0b80cf56 1719.BR getpid (2)
c60237c9
MK
1720.I should
1721return the same value in the child and in the process that called
1722.BR clone (),
a1d48abb 1723since the caller and the child are in the same thread group.
e7d807b7 1724The stale-cache problem also does not occur if the
a1d48abb
JR
1725.I flags
1726argument includes
1727.BR CLONE_VM .)
abcf3b1d
MK
1728To get the truth, it was sometimes necessary to use code such as the following:
1729.PP
47f743f1
MK
1730.in +4n
1731.EX
1732#include <syscall.h>
31830ef0 1733
47f743f1 1734pid_t mypid;
31830ef0 1735
47f743f1
MK
1736mypid = syscall(SYS_getpid);
1737.EE
1738.in
c60237c9
MK
1739.\" See also the following bug reports
1740.\" https://bugzilla.redhat.com/show_bug.cgi?id=417521
1741.\" http://sourceware.org/bugzilla/show_bug.cgi?id=6910
abcf3b1d
MK
1742.PP
1743Because of the stale-cache problem, as well as other problems noted in
1744.BR getpid (2),
1745the PID caching feature was removed in glibc 2.25.
8c7b566c 1746.SH EXAMPLE
8c7b566c 1747The following program demonstrates the use of
9c13072a 1748.BR clone ()
8c7b566c
MK
1749to create a child process that executes in a separate UTS namespace.
1750The child changes the hostname in its UTS namespace.
1751Both parent and child then display the system hostname,
1752making it possible to see that the hostname
1753differs in the UTS namespaces of the parent and child.
1754For an example of the use of this program, see
1755.BR setns (2).
99c3a000
MK
1756.PP
1757Within the sample program, we allocate the memory that is to
1758be used for the child's stack using
1759.BR mmap (2)
1760rather than
1761.BR malloc (3)
1762for the following reasons:
1763.IP * 3
1764.BR mmap (2)
1765allocates a block of memory that starts on a page
1766boundary and is a multiple of the page size.
1767This is useful if we want to establish a guard page (a page with protection
1768.BR PROT_NONE )
1769at the end of the stack using
1770.BR mprotect (2).
1771.IP *
1772We can specify the
1773.BR MAP_STACK
1774flag to request a mapping that is suitable for a stack.
1775For the moment, this flag is a no-op on Linux,
1776but it exists and has effect on some other systems,
1777so we should include it for portability.
f30b7415 1778.SS Program source
e7d0bb47 1779.EX
8c7b566c
MK
1780#define _GNU_SOURCE
1781#include <sys/wait.h>
1782#include <sys/utsname.h>
1783#include <sched.h>
1784#include <string.h>
1785#include <stdio.h>
1786#include <stdlib.h>
1787#include <unistd.h>
99c3a000 1788#include <sys/mman.h>
8c7b566c 1789
d1a71985 1790#define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); \e
8c7b566c
MK
1791 } while (0)
1792
1793static int /* Start function for cloned child */
1794childFunc(void *arg)
1795{
1796 struct utsname uts;
1797
1798 /* Change hostname in UTS namespace of child */
1799
1800 if (sethostname(arg, strlen(arg)) == \-1)
1801 errExit("sethostname");
1802
07d4e6ea 1803 /* Retrieve and display hostname */
8c7b566c
MK
1804
1805 if (uname(&uts) == \-1)
1806 errExit("uname");
d1a71985 1807 printf("uts.nodename in child: %s\en", uts.nodename);
8c7b566c
MK
1808
1809 /* Keep the namespace open for a while, by sleeping.
1810 This allows some experimentation\-\-for example, another
1811 process might join the namespace. */
9f1b9726 1812
8c7b566c
MK
1813 sleep(200);
1814
1815 return 0; /* Child terminates now */
1816}
1817
1818#define STACK_SIZE (1024 * 1024) /* Stack size for cloned child */
1819
1820int
1821main(int argc, char *argv[])
1822{
1823 char *stack; /* Start of stack buffer */
1824 char *stackTop; /* End of stack buffer */
1825 pid_t pid;
1826 struct utsname uts;
1827
1828 if (argc < 2) {
d1a71985 1829 fprintf(stderr, "Usage: %s <child\-hostname>\en", argv[0]);
8c7b566c
MK
1830 exit(EXIT_SUCCESS);
1831 }
1832
99c3a000 1833 /* Allocate memory to be used for the stack of the child */
8c7b566c 1834
99c3a000
MK
1835 stack = mmap(NULL, STACK_SIZE, PROT_READ | PROT_WRITE,
1836 MAP_PRIVATE | MAP_ANONYMOUS | MAP_STACK, \-1, 0);
8eea66b8 1837 if (stack == MAP_FAILED)
99c3a000
MK
1838 errExit("mmap");
1839
8c7b566c
MK
1840 stackTop = stack + STACK_SIZE; /* Assume stack grows downward */
1841
1842 /* Create child that has its own UTS namespace;
1843 child commences execution in childFunc() */
1844
1845 pid = clone(childFunc, stackTop, CLONE_NEWUTS | SIGCHLD, argv[1]);
1846 if (pid == \-1)
1847 errExit("clone");
d1a71985 1848 printf("clone() returned %ld\en", (long) pid);
8c7b566c
MK
1849
1850 /* Parent falls through to here */
1851
1852 sleep(1); /* Give child time to change its hostname */
1853
9f1b9726 1854 /* Display hostname in parent\(aqs UTS namespace. This will be
8c7b566c
MK
1855 different from hostname in child\(aqs UTS namespace. */
1856
1857 if (uname(&uts) == \-1)
1858 errExit("uname");
d1a71985 1859 printf("uts.nodename in parent: %s\en", uts.nodename);
8c7b566c
MK
1860
1861 if (waitpid(pid, NULL, 0) == \-1) /* Wait for child */
1862 errExit("waitpid");
d1a71985 1863 printf("child has terminated\en");
8c7b566c
MK
1864
1865 exit(EXIT_SUCCESS);
1866}
e7d0bb47 1867.EE
47297adb 1868.SH SEE ALSO
fea681da 1869.BR fork (2),
2b44301c 1870.BR futex (2),
fea681da
MK
1871.BR getpid (2),
1872.BR gettid (2),
6f8746e4 1873.BR kcmp (2),
99c3a000 1874.BR mmap (2),
d8837668 1875.BR pidfd_open (2),
f2d0bbf1 1876.BR set_thread_area (2),
2b44301c 1877.BR set_tid_address (2),
8403481f 1878.BR setns (2),
f2d0bbf1 1879.BR tkill (2),
5cc01e9c 1880.BR unshare (2),
fea681da 1881.BR wait (2),
3616b7c0 1882.BR capabilities (7),
41096af1 1883.BR namespaces (7),
3616b7c0 1884.BR pthreads (7)