]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/clone.2
bind.2, chmod.2, chown.2, chroot.2, clock_getres.2, clone.2, connect.2, dup.2, falloc...
[thirdparty/man-pages.git] / man2 / clone.2
CommitLineData
fea681da 1.\" Copyright (c) 1992 Drew Eckhardt <drew@cs.colorado.edu>, March 28, 1992
8c7b566c 2.\" and Copyright (c) Michael Kerrisk, 2001, 2002, 2005, 2013
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.\"
35deeb87 42.TH CLONE 2 2016-12-12 "Linux" "Linux Programmer's Manual"
fea681da 43.SH NAME
9b0e0996 44clone, __clone2 \- create a child process
fea681da 45.SH SYNOPSIS
c10859eb 46.nf
81f10dad
MK
47/* Prototype for the glibc wrapper function */
48
4f71ba5d 49.B #define _GNU_SOURCE
fea681da 50.B #include <sched.h>
c10859eb 51
ff929e3b
MK
52.BI "int clone(int (*" "fn" ")(void *), void *" child_stack ,
53.BI " int " flags ", void *" "arg" ", ... "
dd6d3d2e 54.BI " /* pid_t *" ptid ", void *" newtls \
ff929e3b 55", pid_t *" ctid " */ );"
81f10dad 56
2a15a76b 57/* For the prototype of the raw system call, see NOTES */
c10859eb 58.fi
fea681da 59.SH DESCRIPTION
edcc65ff
MK
60.BR clone ()
61creates a new process, in a manner similar to
fea681da 62.BR fork (2).
81f10dad
MK
63
64This page describes both the glibc
e511ffb6 65.BR clone ()
e585064b 66wrapper function and the underlying system call on which it is based.
81f10dad 67The main text describes the wrapper function;
e585064b 68the differences for the raw system call
81f10dad 69are described toward the end of this page.
fea681da
MK
70
71Unlike
72.BR fork (2),
81f10dad
MK
73.BR clone ()
74allows the child process to share parts of its execution context with
fea681da 75the calling process, such as the memory space, the table of file
c13182ef
MK
76descriptors, and the table of signal handlers.
77(Note that on this manual
78page, "calling process" normally corresponds to "parent process".
79But see the description of
80.B CLONE_PARENT
fea681da
MK
81below.)
82
1533d242 83One use of
edcc65ff 84.BR clone ()
fea681da
MK
85is to implement threads: multiple threads of control in a program that
86run concurrently in a shared memory space.
87
88When the child process is created with
c13182ef 89.BR clone (),
fea681da 90it executes the function
c13182ef 91.IR fn ( arg ).
fea681da 92(This differs from
c13182ef 93.BR fork (2),
fea681da 94where execution continues in the child from the point
c13182ef
MK
95of the
96.BR fork (2)
fea681da
MK
97call.)
98The
99.I fn
100argument is a pointer to a function that is called by the child
101process at the beginning of its execution.
102The
103.I arg
104argument is passed to the
105.I fn
106function.
107
c13182ef 108When the
fea681da 109.IR fn ( arg )
c13182ef
MK
110function application returns, the child process terminates.
111The integer returned by
fea681da 112.I fn
c13182ef
MK
113is the exit code for the child process.
114The child process may also terminate explicitly by calling
fea681da
MK
115.BR exit (2)
116or after receiving a fatal signal.
117
118The
119.I child_stack
c13182ef
MK
120argument specifies the location of the stack used by the child process.
121Since the child and calling process may share memory,
fea681da 122it is not possible for the child process to execute in the
c13182ef
MK
123same stack as the calling process.
124The calling process must therefore
fea681da
MK
125set up memory space for the child stack and pass a pointer to this
126space to
edcc65ff 127.BR clone ().
5fab2e7c 128Stacks grow downward on all processors that run Linux
fea681da
MK
129(except the HP PA processors), so
130.I child_stack
131usually points to the topmost address of the memory space set up for
132the child stack.
133
134The low byte of
135.I flags
fd8a5be4
MK
136contains the number of the
137.I "termination signal"
138sent to the parent when the child dies.
139If this signal is specified as anything other than
fea681da
MK
140.BR SIGCHLD ,
141then the parent process must specify the
c13182ef
MK
142.B __WALL
143or
fea681da 144.B __WCLONE
c13182ef
MK
145options when waiting for the child with
146.BR wait (2).
fea681da
MK
147If no signal is specified, then the parent process is not signaled
148when the child terminates.
149
150.I flags
fd8a5be4
MK
151may also be bitwise-or'ed with zero or more of the following constants,
152in order to specify what is shared between the calling process
fea681da 153and the child process:
fea681da 154.TP
f5dbc7c8 155.BR CLONE_CHILD_CLEARTID " (since Linux 2.5.49)"
4ba5392d 156Clear (zero) the child thread ID at the location
d3dbc9b1 157.I ctid
f5dbc7c8
MK
158in child memory when the child exits, and do a wakeup on the futex
159at that address.
160The address involved may be changed by the
161.BR set_tid_address (2)
162system call.
163This is used by threading libraries.
164.TP
165.BR CLONE_CHILD_SETTID " (since Linux 2.5.49)"
8ef021ea 166Store the child thread ID at the location
d3dbc9b1 167.I ctid
8ef021ea 168in the child's memory.
b5da2f91
MK
169The store operation completes before
170.BR clone ()
171returns control to user space.
f5dbc7c8 172.TP
1603d6a1 173.BR CLONE_FILES " (since Linux 2.0)"
fea681da 174If
f5dbc7c8
MK
175.B CLONE_FILES
176is set, the calling process and the child process share the same file
177descriptor table.
178Any file descriptor created by the calling process or by the child
179process is also valid in the other process.
180Similarly, if one of the processes closes a file descriptor,
181or changes its associated flags (using the
182.BR fcntl (2)
183.B F_SETFD
184operation), the other process is also affected.
8a76b19e
KE
185If a process sharing a file descriptor table calls
186.BR execve (2),
187its file descriptor table is duplicated (unshared).
fea681da
MK
188
189If
f5dbc7c8
MK
190.B CLONE_FILES
191is not set, the child process inherits a copy of all file descriptors
192opened in the calling process at the time of
193.BR clone ().
f5dbc7c8
MK
194Subsequent operations that open or close file descriptors,
195or change file descriptor flags,
196performed by either the calling
197process or the child process do not affect the other process.
db8ba2b4
MK
198Note, however,
199that the duplicated file descriptors in the child refer to the same open file
200descriptions as the corresponding file descriptors in the calling process,
2433365b 201and thus share file offsets and file status flags (see
db8ba2b4 202.BR open (2)).
fea681da 203.TP
1603d6a1 204.BR CLONE_FS " (since Linux 2.0)"
fea681da
MK
205If
206.B CLONE_FS
9ee4a2b6 207is set, the caller and the child process share the same filesystem
c13182ef 208information.
9ee4a2b6 209This includes the root of the filesystem, the current
c13182ef
MK
210working directory, and the umask.
211Any call to
fea681da
MK
212.BR chroot (2),
213.BR chdir (2),
214or
215.BR umask (2)
edcc65ff 216performed by the calling process or the child process also affects the
fea681da
MK
217other process.
218
c13182ef 219If
fea681da 220.B CLONE_FS
9ee4a2b6 221is not set, the child process works on a copy of the filesystem
fea681da 222information of the calling process at the time of the
edcc65ff 223.BR clone ()
fea681da
MK
224call.
225Calls to
226.BR chroot (2),
227.BR chdir (2),
228.BR umask (2)
229performed later by one of the processes do not affect the other process.
fea681da 230.TP
a4cc375e 231.BR CLONE_IO " (since Linux 2.6.25)"
11f27a1c
JA
232If
233.B CLONE_IO
234is set, then the new process shares an I/O context with
235the calling process.
236If this flag is not set, then (as with
237.BR fork (2))
238the new process has its own I/O context.
239
240.\" The following based on text from Jens Axboe
d1f84ed7 241The I/O context is the I/O scope of the disk scheduler (i.e.,
11f27a1c
JA
242what the I/O scheduler uses to model scheduling of a process's I/O).
243If processes share the same I/O context,
244they are treated as one by the I/O scheduler.
245As a consequence, they get to share disk time.
246For some I/O schedulers,
247.\" the anticipatory and CFQ scheduler
248if two processes share an I/O context,
249they will be allowed to interleave their disk access.
250If several threads are doing I/O on behalf of the same process
251.RB ( aio_read (3),
252for instance), they should employ
253.BR CLONE_IO
254to get better I/O performance.
255.\" with CFQ and AS.
256
257If the kernel is not configured with the
258.B CONFIG_BLOCK
259option, this flag is a no-op.
260.TP
c5af0674
MK
261.BR CLONE_NEWCGROUP " (since Linux 4.6)"
262Create the process in a new cgroup namespace.
263If this flag is not set, then (as with
264.BR fork (2))
265the process is created in the same cgroup namespaces as the calling process.
266This flag is intended for the implementation of containers.
267
268For further information on cgroup namespaces, see
b9fe4bc3 269.BR cgroup_namespaces (7).
c5af0674
MK
270
271Only a privileged process
272.RB ( CAP_SYS_ADMIN )
273can employ
274.BR CLONE_NEWCGROUP .
275.\"
276.TP
8722311b 277.BR CLONE_NEWIPC " (since Linux 2.6.19)"
667417b3
MK
278If
279.B CLONE_NEWIPC
280is set, then create the process in a new IPC namespace.
281If this flag is not set, then (as with
06b30458 282.BR fork (2)),
667417b3
MK
283the process is created in the same IPC namespace as
284the calling process.
0236bea9 285This flag is intended for the implementation of containers.
667417b3 286
efbfd7ec 287An IPC namespace provides an isolated view of System\ V IPC objects (see
009a049e
MK
288.BR svipc (7))
289and (since Linux 2.6.30)
290.\" commit 7eafd7c74c3f2e67c27621b987b28397110d643f
291.\" https://lwn.net/Articles/312232/
292POSIX message queues
293(see
294.BR mq_overview (7)).
19911fa5
MK
295The common characteristic of these IPC mechanisms is that IPC
296objects are identified by mechanisms other than filesystem
297pathnames.
009a049e 298
c440fe01 299Objects created in an IPC namespace are visible to all other processes
667417b3
MK
300that are members of that namespace,
301but are not visible to processes in other IPC namespaces.
302
83c1f4b5 303When an IPC namespace is destroyed
009a049e 304(i.e., when the last process that is a member of the namespace terminates),
83c1f4b5
MK
305all IPC objects in the namespace are automatically destroyed.
306
ab5dd83f
MK
307Only a privileged process
308.RB ( CAP_SYS_ADMIN )
309can employ
310.BR CLONE_NEWIPC .
667417b3
MK
311This flag can't be specified in conjunction with
312.BR CLONE_SYSVSEM .
9343f8e7
MK
313
314For further information on IPC namespaces, see
315.BR namespaces (7).
667417b3 316.TP
163bf178 317.BR CLONE_NEWNET " (since Linux 2.6.24)"
33a0ccb2 318(The implementation of this flag was completed only
9108d867 319by about kernel version 2.6.29.)
163bf178
MK
320
321If
322.B CLONE_NEWNET
323is set, then create the process in a new network namespace.
324If this flag is not set, then (as with
57ef8c39 325.BR fork (2))
163bf178
MK
326the process is created in the same network namespace as
327the calling process.
328This flag is intended for the implementation of containers.
329
330A network namespace provides an isolated view of the networking stack
331(network device interfaces, IPv4 and IPv6 protocol stacks,
332IP routing tables, firewall rules, the
333.I /proc/net
334and
335.I /sys/class/net
336directory trees, sockets, etc.).
337A physical network device can live in exactly one
338network namespace.
339A virtual network device ("veth") pair provides a pipe-like abstraction
bea08fec 340.\" FIXME . Add pointer to veth(4) page when it is eventually completed
163bf178
MK
341that can be used to create tunnels between network namespaces,
342and can be used to create a bridge to a physical network device
343in another namespace.
344
bf032425
SH
345When a network namespace is freed
346(i.e., when the last process in the namespace terminates),
347its physical network devices are moved back to the
348initial network namespace (not to the parent of the process).
73680728
MK
349For further information on network namespaces, see
350.BR namespaces (7).
bf032425 351
ab5dd83f
MK
352Only a privileged process
353.RB ( CAP_SYS_ADMIN )
354can employ
355.BR CLONE_NEWNET .
163bf178 356.TP
c10859eb 357.BR CLONE_NEWNS " (since Linux 2.4.19)"
3dd2331c
MK
358If
359.B CLONE_NEWNS
360is set, the cloned child is started in a new mount namespace,
361initialized with a copy of the namespace of the parent.
362If
fea681da 363.B CLONE_NEWNS
3dd2331c 364is not set, the child lives in the same mount
4df2eb09 365namespace as the parent.
fea681da 366
ab5dd83f
MK
367Only a privileged process
368.RB ( CAP_SYS_ADMIN )
369can employ
370.BR CLONE_NEWNS .
fea681da
MK
371It is not permitted to specify both
372.B CLONE_NEWNS
373and
374.B CLONE_FS
9219d208 375.\" See https://lwn.net/Articles/543273/
fea681da 376in the same
e511ffb6 377.BR clone ()
fea681da 378call.
c212248c
MK
379
380For further information on mount namespaces, see
381.BR namespaces (7)
382and
383.BR mount_namespaces (7).
9d005472
MK
384.TP
385.BR CLONE_NEWPID " (since Linux 2.6.24)"
386.\" This explanation draws a lot of details from
387.\" http://lwn.net/Articles/259217/
388.\" Authors: Pavel Emelyanov <xemul@openvz.org>
389.\" and Kir Kolyshkin <kir@openvz.org>
390.\"
391.\" The primary kernel commit is 30e49c263e36341b60b735cbef5ca37912549264
392.\" Author: Pavel Emelyanov <xemul@openvz.org>
393If
394.B CLONE_NEWPID
395is set, then create the process in a new PID namespace.
396If this flag is not set, then (as with
397.BR fork (2))
398the process is created in the same PID namespace as
399the calling process.
400This flag is intended for the implementation of containers.
401
402For further information on PID namespaces, see
7e0e902b
MK
403.BR namespaces (7)
404and
39b3f005 405.BR pid_namespaces (7).
9d005472 406
ab5dd83f
MK
407Only a privileged process
408.RB ( CAP_SYS_ADMIN )
409can employ
410.BR CLONE_NEWPID .
9d005472 411This flag can't be specified in conjunction with
f0007192
MK
412.BR CLONE_THREAD
413or
414.BR CLONE_PARENT .
70d21f17 415.TP
06b30458
MK
416.BR CLONE_NEWUSER
417(This flag first became meaningful for
418.BR clone ()
4d2b3ed7
MK
419in Linux 2.6.23,
420the current
11a38815 421.BR clone ()
4d2b3ed7
MK
422semantics were merged in Linux 3.5,
423and the final pieces to make the user namespaces completely usable were
424merged in Linux 3.8.)
425
70d21f17
EB
426If
427.B CLONE_NEWUSER
06b30458
MK
428is set, then create the process in a new user namespace.
429If this flag is not set, then (as with
57ef8c39 430.BR fork (2))
70d21f17
EB
431the process is created in the same user namespace as the calling process.
432
9d005472 433For further information on user namespaces, see
f58fb24f
MK
434.BR namespaces (7)
435and
436.BR user_namespaces (7)
06b30458 437
fefbcba8
MK
438Before Linux 3.8, use of
439.BR CLONE_NEWUSER
440required that the caller have three capabilities:
441.BR CAP_SYS_ADMIN ,
442.BR CAP_SETUID ,
443and
444.BR CAP_SETGID .
445.\" Before Linux 2.6.29, it appears that only CAP_SYS_ADMIN was needed
06b30458 446Starting with Linux 3.8,
9d005472 447no privileges are needed to create a user namespace.
f0007192 448
5e72cf7d
MK
449This flag can't be specified in conjunction with
450.BR CLONE_THREAD
451or
452.BR CLONE_PARENT .
453For security reasons,
454.\" commit e66eded8309ebf679d3d3c1f5820d1f2ca332c71
455.\" https://lwn.net/Articles/543273/
456.\" The fix actually went into 3.9 and into 3.8.3. However, user namespaces
457.\" were, for practical purposes, unusable in earlier 3.8.x because of the
ab3311aa 458.\" various filesystems that didn't support userns.
f0007192
MK
459.BR CLONE_NEWUSER
460cannot be specified in conjunction with
5e72cf7d
MK
461.BR CLONE_FS .
462
463For further information on user namespaces, see
464.BR user_namespaces (7).
82ee147a 465.TP
43ce9dda
MK
466.BR CLONE_NEWUTS " (since Linux 2.6.19)"
467If
468.B CLONE_NEWUTS
e1b11906
MK
469is set, then create the process in a new UTS namespace,
470whose identifiers are initialized by duplicating the identifiers
471from the UTS namespace of the calling process.
43ce9dda 472If this flag is not set, then (as with
57ef8c39 473.BR fork (2))
43ce9dda
MK
474the process is created in the same UTS namespace as
475the calling process.
0236bea9 476This flag is intended for the implementation of containers.
43ce9dda
MK
477
478A UTS namespace is the set of identifiers returned by
479.BR uname (2);
850905cf 480among these, the domain name and the hostname can be modified by
43ce9dda
MK
481.BR setdomainname (2)
482and
43ce9dda
MK
483.BR sethostname (2),
484respectively.
c440fe01
MK
485Changes made to the identifiers in a UTS namespace
486are visible to all other processes in the same namespace,
43ce9dda
MK
487but are not visible to processes in other UTS namespaces.
488
ab5dd83f
MK
489Only a privileged process
490.RB ( CAP_SYS_ADMIN )
491can employ
492.BR CLONE_NEWUTS .
9cc7ad66 493
83d9e9b2 494For further information on UTS namespaces, see
9cc7ad66 495.BR namespaces (7).
43ce9dda 496.TP
f5dbc7c8
MK
497.BR CLONE_PARENT " (since Linux 2.3.12)"
498If
499.B CLONE_PARENT
500is set, then the parent of the new child (as returned by
501.BR getppid (2))
502will be the same as that of the calling process.
503
504If
505.B CLONE_PARENT
506is not set, then (as with
507.BR fork (2))
508the child's parent is the calling process.
509
510Note that it is the parent process, as returned by
511.BR getppid (2),
512which is signaled when the child terminates, so that
513if
514.B CLONE_PARENT
515is set, then the parent of the calling process, rather than the
516calling process itself, will be signaled.
517.TP
518.BR CLONE_PARENT_SETTID " (since Linux 2.5.49)"
8ef021ea 519Store the child thread ID at the location
d3dbc9b1 520.I ptid
8ef021ea 521in the parent's memory.
f5dbc7c8
MK
522(In Linux 2.5.32-2.5.48 there was a flag
523.B CLONE_SETTID
524that did this.)
b5da2f91
MK
525The store operation completes before
526.BR clone ()
527returns control to user space.
f5dbc7c8
MK
528.TP
529.BR CLONE_PID " (obsolete)"
530If
531.B CLONE_PID
532is set, the child process is created with the same process ID as
533the calling process.
534This is good for hacking the system, but otherwise
535of not much use.
536Since 2.3.21 this flag can be
537specified only by the system boot process (PID 0).
28b44abc
MK
538It disappeared in Linux 2.5.16.
539Since then, the kernel silently ignores it without error.
f5dbc7c8 540.TP
1603d6a1 541.BR CLONE_PTRACE " (since Linux 2.2)"
f5dbc7c8
MK
542If
543.B CLONE_PTRACE
544is specified, and the calling process is being traced,
545then trace the child also (see
546.BR ptrace (2)).
547.TP
548.BR CLONE_SETTLS " (since Linux 2.5.32)"
dd6d3d2e
KF
549The TLS (Thread Local Storage) descriptor is set to
550.I newtls.
551
552The interpretation of
553.I newtls
554and the resulting effect is architecture dependent.
555On x86,
f5dbc7c8 556.I newtls
dd6d3d2e
KF
557is interpreted as a
558.IR "struct user_desc *"
f5dbc7c8 559(See
dd6d3d2e
KF
560.BR set_thread_area (2)).
561On x86_64 it is the new value to be set for the %fs base register
562(See the
563.I ARCH_SET_FS
564argument to
565.BR arch_prctl (2)).
566On architectures with a dedicated TLS register, it is the new value
567of that register.
f5dbc7c8 568.TP
1603d6a1 569.BR CLONE_SIGHAND " (since Linux 2.0)"
fea681da
MK
570If
571.B CLONE_SIGHAND
314c8ff4 572is set, the calling process and the child process share the same table of
c13182ef
MK
573signal handlers.
574If the calling process or child process calls
fea681da 575.BR sigaction (2)
c13182ef
MK
576to change the behavior associated with a signal, the behavior is
577changed in the other process as well.
578However, the calling process and child
fea681da 579processes still have distinct signal masks and sets of pending
c13182ef
MK
580signals.
581So, one of them may block or unblock some signals using
fea681da
MK
582.BR sigprocmask (2)
583without affecting the other process.
584
585If
586.B CLONE_SIGHAND
587is not set, the child process inherits a copy of the signal handlers
588of the calling process at the time
edcc65ff 589.BR clone ()
c13182ef
MK
590is called.
591Calls to
fea681da
MK
592.BR sigaction (2)
593performed later by one of the processes have no effect on the other
594process.
29546c24
MK
595
596Since Linux 2.6.0-test6,
597.I flags
598must also include
599.B CLONE_VM
600if
601.B CLONE_SIGHAND
602is specified
fea681da 603.TP
a69b6bda
MK
604.BR CLONE_STOPPED " (since Linux 2.6.0-test2)"
605If
606.B CLONE_STOPPED
607is set, then the child is initially stopped (as though it was sent a
608.B SIGSTOP
609signal), and must be resumed by sending it a
610.B SIGCONT
611signal.
ef37eaf2 612
a60450a9
MK
613This flag was
614.I deprecated
615from Linux 2.6.25 onward,
616and was
617.I removed
28b44abc
MK
618altogether in Linux 2.6.38.
619Since then, the kernel silently ignores it without error.
a5a061ee 620.\" glibc 2.8 removed this defn from bits/sched.h
c5af0674
MK
621Starting with Linux 4.6, the same bit was reused for the
622.BR CLONE_NEWCGROUP
623flag.
a69b6bda 624.TP
f5dbc7c8 625.BR CLONE_SYSVSEM " (since Linux 2.5.10)"
fea681da 626If
f5dbc7c8
MK
627.B CLONE_SYSVSEM
628is set, then the child and the calling process share
5ada4b94
MK
629a single list of System V semaphore adjustment
630.RI ( semadj )
631values (see
f5dbc7c8 632.BR semop (2)).
5ada4b94
MK
633In this case, the shared list accumulates
634.I semadj
635values across all processes sharing the list,
636and semaphore adjustments are performed only when the last process
637that is sharing the list terminates (or ceases sharing the list using
638.BR unshare (2)).
f5d401dd 639If this flag is not set, then the child has a separate
5ada4b94
MK
640.I semadj
641list that is initially empty.
fea681da
MK
642.TP
643.BR CLONE_THREAD " (since Linux 2.4.0-test8)"
644If
645.B CLONE_THREAD
646is set, the child is placed in the same thread group as the calling process.
fd8a5be4
MK
647To make the remainder of the discussion of
648.B CLONE_THREAD
649more readable, the term "thread" is used to refer to the
650processes within a thread group.
fea681da 651
fd8a5be4
MK
652Thread groups were a feature added in Linux 2.4 to support the
653POSIX threads notion of a set of threads that share a single PID.
654Internally, this shared PID is the so-called
655thread group identifier (TGID) for the thread group.
c13182ef 656Since Linux 2.4, calls to
fea681da 657.BR getpid (2)
fd8a5be4
MK
658return the TGID of the caller.
659
660The threads within a group can be distinguished by their (system-wide)
661unique thread IDs (TID).
662A new thread's TID is available as the function result
663returned to the caller of
664.BR clone (),
665and a thread can obtain
666its own TID using
667.BR gettid (2).
668
c13182ef 669When a call is made to
fd8a5be4
MK
670.BR clone ()
671without specifying
672.BR CLONE_THREAD ,
673then the resulting thread is placed in a new thread group
674whose TGID is the same as the thread's TID.
675This thread is the
676.I leader
677of the new thread group.
678
679A new thread created with
680.B CLONE_THREAD
681has the same parent process as the caller of
682.BR clone ()
c13182ef 683(i.e., like
fd8a5be4
MK
684.BR CLONE_PARENT ),
685so that calls to
686.BR getppid (2)
687return the same value for all of the threads in a thread group.
688When a
c13182ef 689.B CLONE_THREAD
fd8a5be4
MK
690thread terminates, the thread that created it using
691.BR clone ()
692is not sent a
693.B SIGCHLD
694(or other termination) signal;
695nor can the status of such a thread be obtained
696using
697.BR wait (2).
698(The thread is said to be
699.IR detached .)
700
e2fbf61d
MK
701After all of the threads in a thread group terminate
702the parent process of the thread group is sent a
fd8a5be4
MK
703.B SIGCHLD
704(or other termination) signal.
705
706If any of the threads in a thread group performs an
707.BR execve (2),
708then all threads other than the thread group leader are terminated,
709and the new program is executed in the thread group leader.
710
f7110f60
MK
711If one of the threads in a thread group creates a child using
712.BR fork (2),
713then any thread in the group can
714.BR wait (2)
715for that child.
716
edcc65ff 717Since Linux 2.5.35,
fd8a5be4
MK
718.I flags
719must also include
720.B CLONE_SIGHAND
721if
722.B CLONE_THREAD
6fd69f33
MK
723is specified
724(and note that, since Linux 2.6.0-test6,
725.BR CLONE_SIGHAND
726also requires
727.BR CLONE_VM
728to be included).
e2fbf61d
MK
729
730Signals may be sent to a thread group as a whole (i.e., a TGID) using
731.BR kill (2),
732or to a specific thread (i.e., TID) using
733.BR tgkill (2).
734
735Signal dispositions and actions are process-wide:
736if an unhandled signal is delivered to a thread, then
737it will affect (terminate, stop, continue, be ignored in)
738all members of the thread group.
739
99408a60 740Each thread has its own signal mask, as set by
e2fbf61d 741.BR sigprocmask (2),
82a06020 742but signals can be pending either: for the whole process
e2fbf61d
MK
743(i.e., deliverable to any member of the thread group),
744when sent with
82a06020 745.BR kill (2);
e2fbf61d
MK
746or for an individual thread, when sent with
747.BR tgkill (2).
99408a60
MK
748A call to
749.BR sigpending (2)
750returns a signal set that is the union of the signals pending for the
751whole process and the signals that are pending for the calling thread.
e2fbf61d 752
c13182ef 753If
e2fbf61d
MK
754.BR kill (2)
755is used to send a signal to a thread group,
756and the thread group has installed a handler for the signal, then
757the handler will be invoked in exactly one, arbitrarily selected
758member of the thread group that has not blocked the signal.
c13182ef 759If multiple threads in a group are waiting to accept the same signal using
e2fbf61d
MK
760.BR sigwaitinfo (2),
761the kernel will arbitrarily select one of these threads
c13182ef 762to receive a signal sent using
e2fbf61d 763.BR kill (2).
a69b6bda 764.TP
f5dbc7c8 765.BR CLONE_UNTRACED " (since Linux 2.5.46)"
a69b6bda 766If
f5dbc7c8
MK
767.B CLONE_UNTRACED
768is specified, then a tracing process cannot force
769.B CLONE_PTRACE
770on this child process.
fea681da 771.TP
1603d6a1 772.BR CLONE_VFORK " (since Linux 2.2)"
f5dbc7c8
MK
773If
774.B CLONE_VFORK
775is set, the execution of the calling process is suspended
776until the child releases its virtual memory
777resources via a call to
778.BR execve (2)
779or
780.BR _exit (2)
781(as with
782.BR vfork (2)).
783
784If
785.B CLONE_VFORK
4b4a853a 786is not set, then both the calling process and the child are schedulable
f5dbc7c8
MK
787after the call, and an application should not rely on execution occurring
788in any particular order.
fea681da 789.TP
1603d6a1 790.BR CLONE_VM " (since Linux 2.0)"
f5dbc7c8
MK
791If
792.B CLONE_VM
793is set, the calling process and the child process run in the same memory
794space.
795In particular, memory writes performed by the calling process
796or by the child process are also visible in the other process.
797Moreover, any memory mapping or unmapping performed with
798.BR mmap (2)
799or
800.BR munmap (2)
801by the child or calling process also affects the other process.
802
803If
804.B CLONE_VM
805is not set, the child process runs in a separate copy of the memory
806space of the calling process at the time of
807.BR clone ().
808Memory writes or file mappings/unmappings performed by one of the
809processes do not affect the other, as with
810.BR fork (2).
0722a578 811.SS C library/kernel differences
e585064b
MK
812The raw
813.BR clone ()
fea681da
MK
814system call corresponds more closely to
815.BR fork (2)
816in that execution in the child continues from the point of the
c13182ef 817call.
5add3af3
MK
818As such, the
819.I fn
c13182ef 820and
5add3af3
MK
821.I arg
822arguments of the
823.BR clone ()
824wrapper function are omitted.
825Furthermore, the argument order changes.
2a15a76b
MK
826In addition, there are variations across architectures.
827
828The raw system call interface on x86-64 and some other architectures
829(including sh, tile, and alpha) is roughly:
830
5add3af3
MK
831.in +4
832.nf
2a15a76b
MK
833.BI "long clone(unsigned long " flags ", void *" child_stack ,
834.BI " int *" ptid ", int *" ctid ,
835.BI " unsigned long " newtls );
836.fi
837.in
838
839On x86-32, and several other common architectures
840(including score, ARM, ARM 64, PA-RISC, arc, Power PC, xtensa,
841and MIPS),
842.\" CONFIG_CLONE_BACKWARDS
843the order of the last two arguments is reversed:
5add3af3 844
2a15a76b
MK
845.in +4
846.nf
5add3af3 847.BI "long clone(unsigned long " flags ", void *" child_stack ,
2a15a76b
MK
848.BI " int *" ptid ", unsigned long " newtls ,
849.BI " int *" ctid );
850.fi
851.in
852
853On the cris and s390 architectures,
854.\" CONFIG_CLONE_BACKWARDS2
855the order of the first two arguments is reversed:
856
857.in +4
858.nf
859.BI "long clone(void *" child_stack ", unsigned long " flags ,
fda55470 860.BI " int *" ptid ", int *" ctid ,
dd6d3d2e 861.BI " unsigned long " newtls );
2a15a76b
MK
862.fi
863.in
864
865On the microblaze architecture,
866.\" CONFIG_CLONE_BACKWARDS3
867an additional argument is supplied:
fea681da 868
2a15a76b
MK
869.in +4
870.nf
871.BI "long clone(unsigned long " flags ", void *" child_stack ,
872.BI " int " stack_size , "\fR /* Size of stack */"
873.BI " int *" ptid ", int *" ctid ,
874.BI " unsigned long " newtls );
5add3af3
MK
875.fi
876.in
2a15a76b 877
e585064b 878Another difference for the raw system call is that the
fea681da 879.I child_stack
c13182ef 880argument may be zero, in which case copy-on-write semantics ensure that the
fea681da 881child gets separate copies of stack pages when either process modifies
c13182ef
MK
882the stack.
883In this case, for correct operation, the
fea681da
MK
884.B CLONE_VM
885option should not be specified.
2a15a76b 886.\"
251113d0 887.SS blackfin, m68k, and sparc
2a15a76b
MK
888.\" Mike Frysinger noted in a 2013 mail:
889.\" these arches don't define __ARCH_WANT_SYS_CLONE:
890.\" blackfin ia64 m68k sparc
251113d0 891The argument-passing conventions on
04346be5 892blackfin, m68k, and sparc are different from the descriptions above.
251113d0 893For details, see the kernel (and glibc) source.
574c92b6 894.SS ia64
097a1f3b
MK
895On ia64, a different interface is used:
896.nf
897
898.BI "int __clone2(int (*" "fn" ")(void *), "
899.BI " void *" child_stack_base ", size_t " stack_size ,
900.BI " int " flags ", void *" "arg" ", ... "
901.BI " /* pid_t *" ptid ", struct user_desc *" tls \
902", pid_t *" ctid " */ );"
903.fi
904.PP
905The prototype shown above is for the glibc wrapper function;
906the raw system call interface has no
907.I fn
908or
909.I arg
910argument, and changes the order of the arguments so that
911.I flags
912is the first argument, and
913.I tls
914is the last argument.
915.PP
916.BR __clone2 ()
917operates in the same way as
918.BR clone (),
919except that
920.I child_stack_base
921points to the lowest address of the child's stack area,
922and
923.I stack_size
924specifies the size of the stack pointed to by
925.IR child_stack_base .
5add3af3 926.SS Linux 2.4 and earlier
577f9b62
MK
927In Linux 2.4 and earlier,
928.BR clone ()
929does not take arguments
930.IR ptid ,
931.IR tls ,
932and
130b2e49 933.IR ctid .
47297adb 934.SH RETURN VALUE
0bfa087b
MK
935.\" gettid(2) returns current->pid;
936.\" getpid(2) returns current->tgid;
fea681da 937On success, the thread ID of the child process is returned
c13182ef 938in the caller's thread of execution.
84811e86 939On failure, \-1 is returned
fea681da
MK
940in the caller's context, no child process will be created, and
941.I errno
942will be set appropriately.
fea681da
MK
943.SH ERRORS
944.TP
945.B EAGAIN
e1b6e186
MK
946Too many processes are already running; see
947.BR fork (2).
fea681da
MK
948.TP
949.B EINVAL
950.B CLONE_SIGHAND
951was specified, but
952.B CLONE_VM
2e8a7fb3
MK
953was not.
954(Since Linux 2.6.0-test6.)
fea681da
MK
955.TP
956.B EINVAL
957.B CLONE_THREAD
958was specified, but
959.B CLONE_SIGHAND
6387216b
MK
960was not.
961(Since Linux 2.5.35.)
29546c24
MK
962.\" .TP
963.\" .B EINVAL
964.\" Precisely one of
965.\" .B CLONE_DETACHED
966.\" and
967.\" .B CLONE_THREAD
6387216b
MK
968.\" was specified.
969.\" (Since Linux 2.6.0-test6.)
fea681da
MK
970.TP
971.B EINVAL
d34e5645 972.\" commit e66eded8309ebf679d3d3c1f5820d1f2ca332c71
fea681da
MK
973Both
974.B CLONE_FS
975and
976.B CLONE_NEWNS
977were specified in
978.IR flags .
979.TP
d34e5645
MK
980.BR EINVAL " (since Linux 3.9)"
981Both
982.B CLONE_NEWUSER
983and
984.B CLONE_FS
985were specified in
986.IR flags .
987.TP
fea681da 988.B EINVAL
82ee147a 989Both
667417b3
MK
990.B CLONE_NEWIPC
991and
992.B CLONE_SYSVSEM
993were specified in
994.IR flags .
995.TP
996.B EINVAL
f0007192 997One (or both) of
82ee147a 998.BR CLONE_NEWPID
f0007192
MK
999or
1000.BR CLONE_NEWUSER
1001and one (or both) of
82ee147a 1002.BR CLONE_THREAD
f0007192
MK
1003or
1004.BR CLONE_PARENT
82ee147a
MK
1005were specified in
1006.IR flags .
1007.TP
1008.B EINVAL
d4748fad 1009Returned by the glibc
edcc65ff 1010.BR clone ()
d4748fad
MK
1011wrapper function when
1012.IR fn
1013or
1014.IR child_stack
1015is specified as NULL.
fea681da 1016.TP
28cad2c1 1017.B EINVAL
667417b3
MK
1018.BR CLONE_NEWIPC
1019was specified in
1020.IR flags ,
1021but the kernel was not configured with the
1022.B CONFIG_SYSVIPC
1023and
1024.BR CONFIG_IPC_NS
1025options.
1026.TP
1027.B EINVAL
163bf178
MK
1028.BR CLONE_NEWNET
1029was specified in
1030.IR flags ,
1031but the kernel was not configured with the
1032.B CONFIG_NET_NS
1033option.
1034.TP
1035.B EINVAL
28cad2c1
MK
1036.BR CLONE_NEWPID
1037was specified in
1038.IR flags ,
1039but the kernel was not configured with the
1040.B CONFIG_PID_NS
1041option.
1042.TP
43ce9dda
MK
1043.B EINVAL
1044.BR CLONE_NEWUTS
1045was specified in
1046.IR flags ,
1047but the kernel was not configured with the
1048.B CONFIG_UTS
1049option.
1050.TP
c550a897
MK
1051.B EINVAL
1052.I child_stack
1053is not aligned to a suitable boundary for this architecture.
1054For example, on aarch64,
1055.I child_stack
1056must be a multiple of 16.
1057.TP
fea681da
MK
1058.B ENOMEM
1059Cannot allocate sufficient memory to allocate a task structure for the
1060child, or to copy those parts of the caller's context that need to be
1061copied.
1062.TP
1063.B EPERM
667417b3 1064.BR CLONE_NEWIPC ,
163bf178 1065.BR CLONE_NEWNET ,
43ce9dda
MK
1066.BR CLONE_NEWNS ,
1067.BR CLONE_NEWPID ,
82ee147a 1068or
43ce9dda 1069.BR CLONE_NEWUTS
00b08db3 1070was specified by an unprivileged process (process without \fBCAP_SYS_ADMIN\fP).
fea681da
MK
1071.TP
1072.B EPERM
1073.B CLONE_PID
1074was specified by a process other than process 0.
365d292a
MK
1075.TP
1076.B EPERM
1077.BR CLONE_NEWUSER
1078was specified in
1079.IR flags ,
1080but either the effective user ID or the effective group ID of the caller
1081does not have a mapping in the parent namespace (see
f58fb24f 1082.BR user_namespaces (7)).
6fd119e7 1083.TP
ac007938
MK
1084.BR EPERM " (since Linux 3.9)"
1085.\" commit 3151527ee007b73a0ebd296010f1c0454a919c7d
11a38815
AM
1086.B CLONE_NEWUSER
1087was specified in
ac007938
MK
1088.I flags
1089and the caller is in a chroot environment
1090.\" FIXME What is the rationale for this restriction?
1091(i.e., the caller's root directory does not match the root directory
1092of the mount namespace in which it resides).
1093.TP
6717ee86
MK
1094.BR ERESTARTNOINTR " (since Linux 2.6.17)"
1095.\" commit 4a2c7a7837da1b91468e50426066d988050e4d56
1096System call was interrupted by a signal and will be restarted.
1097(This can be seen only during a trace.)
1098.TP
ac007938 1099.BR EUSERS " (since Linux 3.11)"
6fd119e7
MK
1100.B CLONE_NEWUSER
1101was specified in
1102.IR flags ,
1103and the call would cause the limit on the number of
1104nested user namespaces to be exceeded.
1105See
1106.BR user_namespaces (7).
92b72224
MK
1107.\" .SH VERSIONS
1108.\" There is no entry for
1109.\" .BR clone ()
1110.\" in libc5.
1111.\" glibc2 provides
1112.\" .BR clone ()
1113.\" as described in this manual page.
47297adb 1114.SH CONFORMING TO
a1d5f77c 1115.BR clone ()
e585064b 1116is Linux-specific and should not be used in programs
a1d5f77c 1117intended to be portable.
fea681da 1118.SH NOTES
79bdcc4a
MK
1119The
1120.BR kcmp (2)
1121system call can be used to test whether two processes share various
49dba87f 1122resources such as a file descriptor table,
79bdcc4a
MK
1123System V semaphore undo operations, or a virtual address space.
1124
ca8b1e32 1125In the Linux 2.4.x series,
fd8a5be4
MK
1126.B CLONE_THREAD
1127generally does not make the parent of the new thread the same
1128as the parent of the calling process.
1129However, for kernel versions 2.4.7 to 2.4.18 the
1130.B CLONE_THREAD
1131flag implied the
c13182ef 1132.B CLONE_PARENT
ca8b1e32 1133flag (as in Linux 2.6.0 and later).
fea681da 1134
c13182ef
MK
1135For a while there was
1136.B CLONE_DETACHED
a5053dcb 1137(introduced in 2.5.32):
c13182ef 1138parent wants no child-exit signal.
4d543007 1139In Linux 2.6.2, the need to give this flag together with
c13182ef 1140.B CLONE_THREAD
a5053dcb
MK
1141disappeared.
1142This flag is still defined, but has no effect.
1143
34ccb744 1144On i386,
a5a997ca
MK
1145.BR clone ()
1146should not be called through vsyscall, but directly through
1147.IR "int $0x80" .
31830ef0
MK
1148.SH BUGS
1149Versions of the GNU C library that include the NPTL threading library
c13182ef 1150contain a wrapper function for
0bfa087b 1151.BR getpid (2)
31830ef0 1152that performs caching of PIDs.
c60237c9
MK
1153This caching relies on support in the glibc wrapper for
1154.BR clone (),
1155but as currently implemented,
1156the cache may not be up to date in some circumstances.
1157In particular,
1158if a signal is delivered to the child immediately after the
1159.BR clone ()
1160call, then a call to
0b80cf56 1161.BR getpid (2)
c60237c9
MK
1162in a handler for the signal may return the PID
1163of the calling process ("the parent"),
88619baf 1164if the clone wrapper has not yet had a chance to update the PID
c60237c9
MK
1165cache in the child.
1166(This discussion ignores the case where the child was created using
9291ce36 1167.BR CLONE_THREAD ,
c60237c9 1168when
0b80cf56 1169.BR getpid (2)
c60237c9
MK
1170.I should
1171return the same value in the child and in the process that called
1172.BR clone (),
a1d48abb 1173since the caller and the child are in the same thread group.
e7d807b7 1174The stale-cache problem also does not occur if the
a1d48abb
JR
1175.I flags
1176argument includes
1177.BR CLONE_VM .)
c60237c9 1178To get the truth, it may be necessary to use code such as the following:
31830ef0
MK
1179.nf
1180
1181 #include <syscall.h>
1182
1183 pid_t mypid;
1184
1185 mypid = syscall(SYS_getpid);
1186.fi
c60237c9
MK
1187.\" See also the following bug reports
1188.\" https://bugzilla.redhat.com/show_bug.cgi?id=417521
1189.\" http://sourceware.org/bugzilla/show_bug.cgi?id=6910
8c7b566c 1190.SH EXAMPLE
8c7b566c 1191The following program demonstrates the use of
9c13072a 1192.BR clone ()
8c7b566c
MK
1193to create a child process that executes in a separate UTS namespace.
1194The child changes the hostname in its UTS namespace.
1195Both parent and child then display the system hostname,
1196making it possible to see that the hostname
1197differs in the UTS namespaces of the parent and child.
1198For an example of the use of this program, see
1199.BR setns (2).
f30b7415 1200.SS Program source
8c7b566c
MK
1201.nf
1202#define _GNU_SOURCE
1203#include <sys/wait.h>
1204#include <sys/utsname.h>
1205#include <sched.h>
1206#include <string.h>
1207#include <stdio.h>
1208#include <stdlib.h>
1209#include <unistd.h>
1210
1211#define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); \\
1212 } while (0)
1213
1214static int /* Start function for cloned child */
1215childFunc(void *arg)
1216{
1217 struct utsname uts;
1218
1219 /* Change hostname in UTS namespace of child */
1220
1221 if (sethostname(arg, strlen(arg)) == \-1)
1222 errExit("sethostname");
1223
07d4e6ea 1224 /* Retrieve and display hostname */
8c7b566c
MK
1225
1226 if (uname(&uts) == \-1)
1227 errExit("uname");
1228 printf("uts.nodename in child: %s\\n", uts.nodename);
1229
1230 /* Keep the namespace open for a while, by sleeping.
1231 This allows some experimentation\-\-for example, another
1232 process might join the namespace. */
9f1b9726 1233
8c7b566c
MK
1234 sleep(200);
1235
1236 return 0; /* Child terminates now */
1237}
1238
1239#define STACK_SIZE (1024 * 1024) /* Stack size for cloned child */
1240
1241int
1242main(int argc, char *argv[])
1243{
1244 char *stack; /* Start of stack buffer */
1245 char *stackTop; /* End of stack buffer */
1246 pid_t pid;
1247 struct utsname uts;
1248
1249 if (argc < 2) {
1250 fprintf(stderr, "Usage: %s <child\-hostname>\\n", argv[0]);
1251 exit(EXIT_SUCCESS);
1252 }
1253
1254 /* Allocate stack for child */
1255
1256 stack = malloc(STACK_SIZE);
1257 if (stack == NULL)
1258 errExit("malloc");
1259 stackTop = stack + STACK_SIZE; /* Assume stack grows downward */
1260
1261 /* Create child that has its own UTS namespace;
1262 child commences execution in childFunc() */
1263
1264 pid = clone(childFunc, stackTop, CLONE_NEWUTS | SIGCHLD, argv[1]);
1265 if (pid == \-1)
1266 errExit("clone");
1267 printf("clone() returned %ld\\n", (long) pid);
1268
1269 /* Parent falls through to here */
1270
1271 sleep(1); /* Give child time to change its hostname */
1272
9f1b9726 1273 /* Display hostname in parent\(aqs UTS namespace. This will be
8c7b566c
MK
1274 different from hostname in child\(aqs UTS namespace. */
1275
1276 if (uname(&uts) == \-1)
1277 errExit("uname");
1278 printf("uts.nodename in parent: %s\\n", uts.nodename);
1279
1280 if (waitpid(pid, NULL, 0) == \-1) /* Wait for child */
1281 errExit("waitpid");
1282 printf("child has terminated\\n");
1283
1284 exit(EXIT_SUCCESS);
1285}
1286.fi
47297adb 1287.SH SEE ALSO
fea681da 1288.BR fork (2),
2b44301c 1289.BR futex (2),
fea681da
MK
1290.BR getpid (2),
1291.BR gettid (2),
6f8746e4 1292.BR kcmp (2),
f2d0bbf1 1293.BR set_thread_area (2),
2b44301c 1294.BR set_tid_address (2),
8403481f 1295.BR setns (2),
f2d0bbf1 1296.BR tkill (2),
5cc01e9c 1297.BR unshare (2),
fea681da 1298.BR wait (2),
3616b7c0 1299.BR capabilities (7),
41096af1 1300.BR namespaces (7),
3616b7c0 1301.BR pthreads (7)