]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/clone.2
minor fixes
[thirdparty/man-pages.git] / man2 / clone.2
CommitLineData
fea681da
MK
1.\" Hey Emacs! This file is -*- nroff -*- source.
2.\"
3.\" Copyright (c) 1992 Drew Eckhardt <drew@cs.colorado.edu>, March 28, 1992
1130df60 4.\" and Copyright (c) Michael Kerrisk, 2001, 2002, 2005
fea681da
MK
5.\" May be distributed under the GNU General Public License.
6.\" Modified by Michael Haardt <michael@moria.de>
7.\" Modified 24 Jul 1993 by Rik Faith <faith@cs.unc.edu>
8.\" Modified 21 Aug 1994 by Michael Chastain <mec@shell.portal.com>:
9.\" New man page (copied from 'fork.2').
10.\" Modified 10 June 1995 by Andries Brouwer <aeb@cwi.nl>
11.\" Modified 25 April 1998 by Xavier Leroy <Xavier.Leroy@inria.fr>
12.\" Modified 26 Jun 2001 by Michael Kerrisk
13.\" Mostly upgraded to 2.4.x
14.\" Added prototype for sys_clone() plus description
15.\" Added CLONE_THREAD with a brief description of thread groups
c13182ef 16.\" Added CLONE_PARENT and revised entire page remove ambiguity
fea681da
MK
17.\" between "calling process" and "parent process"
18.\" Added CLONE_PTRACE and CLONE_VFORK
19.\" Added EPERM and EINVAL error codes
fd8a5be4 20.\" Renamed "__clone" to "clone" (which is the prototype in <sched.h>)
fea681da 21.\" various other minor tidy ups and clarifications.
305a0578 22.\" Modified 26 Jun 2001 by Michael Kerrisk <mtk-manpages@gmx.net>
d9bfdb9c 23.\" Updated notes for 2.4.7+ behavior of CLONE_THREAD
305a0578 24.\" Modified 15 Oct 2002 by Michael Kerrisk <mtk-manpages@gmx.net>
fea681da
MK
25.\" Added description for CLONE_NEWNS, which was added in 2.4.19
26.\" Slightly rephrased, aeb.
27.\" Modified 1 Feb 2003 - added CLONE_SIGHAND restriction, aeb.
28.\" Modified 1 Jan 2004 - various updates, aeb
29.\" Modified 2004-09-10 - added CLONE_PARENT_SETTID etc - aeb.
d9bfdb9c 30.\" 2005-04-12, mtk, noted the PID caching behavior of NPTL's getpid()
31830ef0 31.\" wrapper under BUGS.
fd8a5be4
MK
32.\" 2005-05-10, mtk, added CLONE_SYSVSEM, CLONE_UNTRACED, CLONE_STOPPED.
33.\" 2005-05-17, mtk, Substantially enhanced discussion of CLONE_THREAD.
fea681da 34.\"
d9343c5c 35.TH CLONE 2 2007-06-01 "Linux" "Linux Programmer's Manual"
fea681da
MK
36.SH NAME
37clone \- create a child process
38.SH SYNOPSIS
c10859eb 39.nf
fea681da 40.B #include <sched.h>
c10859eb 41
ff929e3b
MK
42.BI "int clone(int (*" "fn" ")(void *), void *" child_stack ,
43.BI " int " flags ", void *" "arg" ", ... "
44.BI " /* pid_t *" pid ", struct user_desc *" tls \
45", pid_t *" ctid " */ );"
c10859eb 46.fi
fea681da 47.SH DESCRIPTION
edcc65ff
MK
48.BR clone ()
49creates a new process, in a manner similar to
fea681da 50.BR fork (2).
735f354f 51It is actually a library function layered on top of the underlying
e511ffb6 52.BR clone ()
fea681da
MK
53system call, hereinafter referred to as
54.BR sys_clone .
55A description of
56.BR sys_clone
57is given towards the end of this page.
58
59Unlike
60.BR fork (2),
c13182ef 61these calls
fea681da
MK
62allow the child process to share parts of its execution context with
63the calling process, such as the memory space, the table of file
c13182ef
MK
64descriptors, and the table of signal handlers.
65(Note that on this manual
66page, "calling process" normally corresponds to "parent process".
67But see the description of
68.B CLONE_PARENT
fea681da
MK
69below.)
70
71The main use of
edcc65ff 72.BR clone ()
fea681da
MK
73is to implement threads: multiple threads of control in a program that
74run concurrently in a shared memory space.
75
76When the child process is created with
c13182ef 77.BR clone (),
fea681da
MK
78it executes the function
79application
c13182ef 80.IR fn ( arg ).
fea681da 81(This differs from
c13182ef 82.BR fork (2),
fea681da 83where execution continues in the child from the point
c13182ef
MK
84of the
85.BR fork (2)
fea681da
MK
86call.)
87The
88.I fn
89argument is a pointer to a function that is called by the child
90process at the beginning of its execution.
91The
92.I arg
93argument is passed to the
94.I fn
95function.
96
c13182ef 97When the
fea681da 98.IR fn ( arg )
c13182ef
MK
99function application returns, the child process terminates.
100The integer returned by
fea681da 101.I fn
c13182ef
MK
102is the exit code for the child process.
103The child process may also terminate explicitly by calling
fea681da
MK
104.BR exit (2)
105or after receiving a fatal signal.
106
107The
108.I child_stack
c13182ef
MK
109argument specifies the location of the stack used by the child process.
110Since the child and calling process may share memory,
fea681da 111it is not possible for the child process to execute in the
c13182ef
MK
112same stack as the calling process.
113The calling process must therefore
fea681da
MK
114set up memory space for the child stack and pass a pointer to this
115space to
edcc65ff 116.BR clone ().
fea681da
MK
117Stacks grow downwards on all processors that run Linux
118(except the HP PA processors), so
119.I child_stack
120usually points to the topmost address of the memory space set up for
121the child stack.
122
123The low byte of
124.I flags
fd8a5be4
MK
125contains the number of the
126.I "termination signal"
127sent to the parent when the child dies.
128If this signal is specified as anything other than
fea681da
MK
129.BR SIGCHLD ,
130then the parent process must specify the
c13182ef
MK
131.B __WALL
132or
fea681da 133.B __WCLONE
c13182ef
MK
134options when waiting for the child with
135.BR wait (2).
fea681da
MK
136If no signal is specified, then the parent process is not signaled
137when the child terminates.
138
139.I flags
fd8a5be4
MK
140may also be bitwise-or'ed with zero or more of the following constants,
141in order to specify what is shared between the calling process
fea681da 142and the child process:
fea681da
MK
143.TP
144.BR CLONE_PARENT " (since Linux 2.3.12)"
145If
146.B CLONE_PARENT
147is set, then the parent of the new child (as returned by
148.BR getppid (2))
149will be the same as that of the calling process.
150
151If
152.B CLONE_PARENT
153is not set, then (as with
154.BR fork (2))
155the child's parent is the calling process.
156
c13182ef 157Note that it is the parent process, as returned by
fea681da
MK
158.BR getppid (2),
159which is signaled when the child terminates, so that
c13182ef 160if
fea681da 161.B CLONE_PARENT
c13182ef 162is set, then the parent of the calling process, rather than the
fea681da 163calling process itself, will be signaled.
fea681da
MK
164.TP
165.B CLONE_FS
166If
167.B CLONE_FS
168is set, the caller and the child processes share the same file system
c13182ef
MK
169information.
170This includes the root of the file system, the current
171working directory, and the umask.
172Any call to
fea681da
MK
173.BR chroot (2),
174.BR chdir (2),
175or
176.BR umask (2)
edcc65ff 177performed by the calling process or the child process also affects the
fea681da
MK
178other process.
179
c13182ef 180If
fea681da
MK
181.B CLONE_FS
182is not set, the child process works on a copy of the file system
183information of the calling process at the time of the
edcc65ff 184.BR clone ()
fea681da
MK
185call.
186Calls to
187.BR chroot (2),
188.BR chdir (2),
189.BR umask (2)
190performed later by one of the processes do not affect the other process.
fea681da
MK
191.TP
192.B CLONE_FILES
193If
194.B CLONE_FILES
195is set, the calling process and the child processes share the same file
edcc65ff 196descriptor table.
c13182ef 197Any file descriptor created by the calling process or by the child
edcc65ff
MK
198process is also valid in the other process.
199Similarly, if one of the processes closes a file descriptor,
200or changes its associated flags (using the
201.BR fcntl (2)
202.B F_SETFD
203operation), the other process is also affected.
fea681da
MK
204
205If
206.B CLONE_FILES
207is not set, the child process inherits a copy of all file descriptors
208opened in the calling process at the time of
edcc65ff
MK
209.BR clone ().
210(The duplicated file descriptors in the child refer to the
c13182ef 211same open file descriptions (see
edcc65ff
MK
212.BR open (2))
213as the corresponding file descriptors in the calling process.)
214Subsequent operations that open or close file descriptors,
215or change file descriptor flags,
c13182ef 216performed by either the calling
edcc65ff 217process or the child process do not affect the other process.
fea681da 218.TP
c10859eb 219.BR CLONE_NEWNS " (since Linux 2.4.19)"
fea681da
MK
220Start the child in a new namespace.
221
c13182ef
MK
222Every process lives in a namespace.
223The
fea681da
MK
224.I namespace
225of a process is the data (the set of mounts) describing the file hierarchy
c13182ef
MK
226as seen by that process.
227After a
fea681da
MK
228.BR fork (2)
229or
230.BR clone (2)
231where the
232.B CLONE_NEWNS
233flag is not set, the child lives in the same namespace as the parent.
234The system calls
235.BR mount (2)
236and
237.BR umount (2)
238change the namespace of the calling process, and hence affect
239all processes that live in the same namespace, but do not affect
240processes in a different namespace.
241
242After a
243.BR clone (2)
244where the
245.B CLONE_NEWNS
246flag is set, the cloned child is started in a new namespace,
247initialized with a copy of the namespace of the parent.
248
249Only a privileged process (one having the CAP_SYS_ADMIN capability)
250may specify the
251.B CLONE_NEWNS
252flag.
253It is not permitted to specify both
254.B CLONE_NEWNS
255and
256.B CLONE_FS
257in the same
e511ffb6 258.BR clone ()
fea681da 259call.
fea681da
MK
260.TP
261.B CLONE_SIGHAND
262If
263.B CLONE_SIGHAND
264is set, the calling process and the child processes share the same table of
c13182ef
MK
265signal handlers.
266If the calling process or child process calls
fea681da 267.BR sigaction (2)
c13182ef
MK
268to change the behavior associated with a signal, the behavior is
269changed in the other process as well.
270However, the calling process and child
fea681da 271processes still have distinct signal masks and sets of pending
c13182ef
MK
272signals.
273So, one of them may block or unblock some signals using
fea681da
MK
274.BR sigprocmask (2)
275without affecting the other process.
276
277If
278.B CLONE_SIGHAND
279is not set, the child process inherits a copy of the signal handlers
280of the calling process at the time
edcc65ff 281.BR clone ()
c13182ef
MK
282is called.
283Calls to
fea681da
MK
284.BR sigaction (2)
285performed later by one of the processes have no effect on the other
286process.
29546c24
MK
287
288Since Linux 2.6.0-test6,
289.I flags
290must also include
291.B CLONE_VM
292if
293.B CLONE_SIGHAND
294is specified
fea681da
MK
295.TP
296.B CLONE_PTRACE
c13182ef 297If
fea681da 298.B CLONE_PTRACE
a69b6bda
MK
299is specified, and the calling process is being traced,
300then trace the child also (see
fea681da 301.BR ptrace (2)).
a69b6bda
MK
302.TP
303.BR CLONE_UNTRACED " (since Linux 2.5.46)"
c13182ef 304If
a69b6bda
MK
305.B CLONE_UNTRACED
306is specified, then a tracing process cannot force
307.B CLONE_PTRACE
308on this child process.
309.TP
310.BR CLONE_STOPPED " (since Linux 2.6.0-test2)"
311If
312.B CLONE_STOPPED
313is set, then the child is initially stopped (as though it was sent a
314.B SIGSTOP
315signal), and must be resumed by sending it a
316.B SIGCONT
317signal.
318.TP
fea681da
MK
319.B CLONE_VFORK
320If
321.B CLONE_VFORK
322is set, the execution of the calling process is suspended
323until the child releases its virtual memory
324resources via a call to
325.BR execve (2)
326or
327.BR _exit (2)
c13182ef 328(as with
fea681da
MK
329.BR vfork (2)).
330
c13182ef 331If
fea681da
MK
332.B CLONE_VFORK
333is not set then both the calling process and the child are schedulable
334after the call, and an application should not rely on execution occurring
335in any particular order.
fea681da
MK
336.TP
337.B CLONE_VM
338If
339.B CLONE_VM
340is set, the calling process and the child processes run in the same memory
c13182ef
MK
341space.
342In particular, memory writes performed by the calling process
fea681da
MK
343or by the child process are also visible in the other process.
344Moreover, any memory mapping or unmapping performed with
345.BR mmap (2)
346or
347.BR munmap (2)
348by the child or calling process also affects the other process.
349
350If
351.B CLONE_VM
352is not set, the child process runs in a separate copy of the memory
353space of the calling process at the time of
edcc65ff 354.BR clone ().
fea681da
MK
355Memory writes or file mappings/unmappings performed by one of the
356processes do not affect the other, as with
357.BR fork (2).
fea681da
MK
358.TP
359.BR CLONE_PID " (obsolete)"
360If
361.B CLONE_PID
c13182ef
MK
362is set, the child process is created with the same process ID as
363the calling process.
364This is good for hacking the system, but otherwise
365of not much use.
366Since 2.3.21 this flag can be
fea681da
MK
367specified only by the system boot process (PID 0).
368It disappeared in Linux 2.5.16.
fea681da
MK
369.TP
370.BR CLONE_THREAD " (since Linux 2.4.0-test8)"
371If
372.B CLONE_THREAD
373is set, the child is placed in the same thread group as the calling process.
fd8a5be4
MK
374To make the remainder of the discussion of
375.B CLONE_THREAD
376more readable, the term "thread" is used to refer to the
377processes within a thread group.
fea681da 378
fd8a5be4
MK
379Thread groups were a feature added in Linux 2.4 to support the
380POSIX threads notion of a set of threads that share a single PID.
381Internally, this shared PID is the so-called
382thread group identifier (TGID) for the thread group.
c13182ef 383Since Linux 2.4, calls to
fea681da 384.BR getpid (2)
fd8a5be4
MK
385return the TGID of the caller.
386
387The threads within a group can be distinguished by their (system-wide)
388unique thread IDs (TID).
389A new thread's TID is available as the function result
390returned to the caller of
391.BR clone (),
392and a thread can obtain
393its own TID using
394.BR gettid (2).
395
c13182ef 396When a call is made to
fd8a5be4
MK
397.BR clone ()
398without specifying
399.BR CLONE_THREAD ,
400then the resulting thread is placed in a new thread group
401whose TGID is the same as the thread's TID.
402This thread is the
403.I leader
404of the new thread group.
405
406A new thread created with
407.B CLONE_THREAD
408has the same parent process as the caller of
409.BR clone ()
c13182ef 410(i.e., like
fd8a5be4
MK
411.BR CLONE_PARENT ),
412so that calls to
413.BR getppid (2)
414return the same value for all of the threads in a thread group.
415When a
c13182ef 416.B CLONE_THREAD
fd8a5be4
MK
417thread terminates, the thread that created it using
418.BR clone ()
419is not sent a
420.B SIGCHLD
421(or other termination) signal;
422nor can the status of such a thread be obtained
423using
424.BR wait (2).
425(The thread is said to be
426.IR detached .)
427
e2fbf61d
MK
428After all of the threads in a thread group terminate
429the parent process of the thread group is sent a
fd8a5be4
MK
430.B SIGCHLD
431(or other termination) signal.
432
433If any of the threads in a thread group performs an
434.BR execve (2),
435then all threads other than the thread group leader are terminated,
436and the new program is executed in the thread group leader.
437
f7110f60
MK
438If one of the threads in a thread group creates a child using
439.BR fork (2),
440then any thread in the group can
441.BR wait (2)
442for that child.
443
edcc65ff 444Since Linux 2.5.35,
fd8a5be4
MK
445.I flags
446must also include
447.B CLONE_SIGHAND
448if
449.B CLONE_THREAD
450is specified.
e2fbf61d
MK
451
452Signals may be sent to a thread group as a whole (i.e., a TGID) using
453.BR kill (2),
454or to a specific thread (i.e., TID) using
455.BR tgkill (2).
456
457Signal dispositions and actions are process-wide:
458if an unhandled signal is delivered to a thread, then
459it will affect (terminate, stop, continue, be ignored in)
460all members of the thread group.
461
99408a60 462Each thread has its own signal mask, as set by
e2fbf61d 463.BR sigprocmask (2),
82a06020 464but signals can be pending either: for the whole process
e2fbf61d
MK
465(i.e., deliverable to any member of the thread group),
466when sent with
82a06020 467.BR kill (2);
e2fbf61d
MK
468or for an individual thread, when sent with
469.BR tgkill (2).
99408a60
MK
470A call to
471.BR sigpending (2)
472returns a signal set that is the union of the signals pending for the
473whole process and the signals that are pending for the calling thread.
e2fbf61d 474
c13182ef 475If
e2fbf61d
MK
476.BR kill (2)
477is used to send a signal to a thread group,
478and the thread group has installed a handler for the signal, then
479the handler will be invoked in exactly one, arbitrarily selected
480member of the thread group that has not blocked the signal.
c13182ef 481If multiple threads in a group are waiting to accept the same signal using
e2fbf61d
MK
482.BR sigwaitinfo (2),
483the kernel will arbitrarily select one of these threads
c13182ef 484to receive a signal sent using
e2fbf61d 485.BR kill (2).
a69b6bda
MK
486.TP
487.BR CLONE_SYSVSEM " (since Linux 2.5.10)"
488If
489.B CLONE_SYSVSEM
490is set, then the child and the calling process share
491a single list of System V semaphore undo values (see
492.BR semop (2)).
493If this flag is not set, then the child has a separate undo list,
494which is initially empty.
fea681da
MK
495.TP
496.BR CLONE_SETTLS " (since Linux 2.5.32)"
497The
498.I newtls
499parameter is the new TLS (Thread Local Storage) descriptor.
500(See
501.BR set_thread_area (2).)
fea681da
MK
502.TP
503.BR CLONE_PARENT_SETTID " (since Linux 2.5.49)"
504Store child thread ID at location
505.I parent_tidptr
506in parent and child memory.
507(In Linux 2.5.32-2.5.48 there was a flag CLONE_SETTID that did this.)
fea681da
MK
508.TP
509.BR CLONE_CHILD_SETTID " (since Linux 2.5.49)"
510Store child thread ID at location
511.I child_tidptr
512in child memory.
fea681da
MK
513.TP
514.BR CLONE_CHILD_CLEARTID " (since Linux 2.5.49)"
515Erase child thread ID at location
516.I child_tidptr
517in child memory when the child exits, and do a wakeup on the futex
518at that address.
519The address involved may be changed by the
520.BR set_tid_address (2)
c13182ef
MK
521system call.
522This is used by threading libraries.
fea681da
MK
523.SS "sys_clone"
524The
525.B sys_clone
526system call corresponds more closely to
527.BR fork (2)
528in that execution in the child continues from the point of the
c13182ef
MK
529call.
530Thus,
fea681da
MK
531.B sys_clone
532only requires the
533.I flags
c13182ef 534and
fea681da 535.I child_stack
c13182ef
MK
536arguments, which have the same meaning as for
537.BR clone ().
fea681da 538(Note that the order of these arguments differs from
c13182ef 539.BR clone ().)
fea681da 540
c13182ef 541Another difference for
fea681da
MK
542.B sys_clone
543is that the
544.I child_stack
c13182ef 545argument may be zero, in which case copy-on-write semantics ensure that the
fea681da 546child gets separate copies of stack pages when either process modifies
c13182ef
MK
547the stack.
548In this case, for correct operation, the
fea681da
MK
549.B CLONE_VM
550option should not be specified.
551
552Since Linux 2.5.49 the system call has five parameters.
553The two new parameters are
554.I parent_tidptr
555which points to the location (in parent and child memory) where
f55c92c4 556the child thread ID will be written in case CLONE_PARENT_SETTID
fea681da
MK
557was specified, and
558.I child_tidptr
559which points to the location (in child memory) where the child thread ID
560will be written in case CLONE_CHILD_SETTID was specified.
fea681da 561.SH "RETURN VALUE"
0bfa087b
MK
562.\" gettid(2) returns current->pid;
563.\" getpid(2) returns current->tgid;
fea681da 564On success, the thread ID of the child process is returned
c13182ef
MK
565in the caller's thread of execution.
566On failure, a \-1 will be returned
fea681da
MK
567in the caller's context, no child process will be created, and
568.I errno
569will be set appropriately.
fea681da
MK
570.SH ERRORS
571.TP
572.B EAGAIN
573Too many processes are already running.
574.TP
575.B EINVAL
576.B CLONE_SIGHAND
577was specified, but
578.B CLONE_VM
2e8a7fb3
MK
579was not.
580(Since Linux 2.6.0-test6.)
fea681da
MK
581.TP
582.B EINVAL
583.B CLONE_THREAD
584was specified, but
585.B CLONE_SIGHAND
586was not. (Since Linux 2.5.35.)
29546c24
MK
587.\" .TP
588.\" .B EINVAL
589.\" Precisely one of
590.\" .B CLONE_DETACHED
591.\" and
592.\" .B CLONE_THREAD
593.\" was specified. (Since Linux 2.6.0-test6.)
fea681da
MK
594.TP
595.B EINVAL
596Both
597.B CLONE_FS
598and
599.B CLONE_NEWNS
600were specified in
601.IR flags .
602.TP
603.B EINVAL
c13182ef 604Returned by
edcc65ff 605.BR clone ()
c13182ef 606when a zero value is specified for
fea681da
MK
607.IR child_stack .
608.TP
609.B ENOMEM
610Cannot allocate sufficient memory to allocate a task structure for the
611child, or to copy those parts of the caller's context that need to be
612copied.
613.TP
614.B EPERM
615.B CLONE_NEWNS
616was specified by a non-root process (process without CAP_SYS_ADMIN).
617.TP
618.B EPERM
619.B CLONE_PID
620was specified by a process other than process 0.
a759cc87 621.SH VERSIONS
fea681da 622There is no entry for
edcc65ff 623.BR clone ()
a759cc87
MK
624in libc5.
625glibc2 provides
edcc65ff 626.BR clone ()
fea681da 627as described in this manual page.
a1d5f77c
MK
628.SH "CONFORMING TO"
629The
630.BR clone ()
631and
632.B sys_clone
633calls are Linux specific and should not be used in programs
634intended to be portable.
fea681da 635.SH NOTES
fd8a5be4
MK
636In the kernel 2.4.x series,
637.B CLONE_THREAD
638generally does not make the parent of the new thread the same
639as the parent of the calling process.
640However, for kernel versions 2.4.7 to 2.4.18 the
641.B CLONE_THREAD
642flag implied the
c13182ef 643.B CLONE_PARENT
fd8a5be4 644flag (as in kernel 2.6).
fea681da 645
c13182ef
MK
646For a while there was
647.B CLONE_DETACHED
a5053dcb 648(introduced in 2.5.32):
c13182ef 649parent wants no child-exit signal.
a5053dcb 650In 2.6.2 the need to give this
c13182ef
MK
651together with
652.B CLONE_THREAD
a5053dcb
MK
653disappeared.
654This flag is still defined, but has no effect.
655
a5a997ca
MK
656On x86,
657.BR clone ()
658should not be called through vsyscall, but directly through
659.IR "int $0x80" .
ff929e3b 660
c13182ef 661On IA-64, a different system call is used:
ff929e3b
MK
662.nf
663
664.BI "int clone2(int (*" "fn" ")(void *), "
665.BI " void *" child_stack_base ", size_t " stack_size ,
666.BI " int " flags ", void *" "arg" ", ... "
667.BI " /* pid_t *" pid ", struct user_desc *" tls \
668", pid_t *" ctid " */ );"
669.fi
670.PP
671The
672.BR clone2 ()
c13182ef 673system call operates in the same way as
ff929e3b
MK
674.BR clone (),
675except that
676.I child_stack_base
677points to the lowest address of the child's stack area,
678and
679.I stack_size
680specifies the size of the stack pointed to by
681.IR child_stack_base .
31830ef0
MK
682.SH BUGS
683Versions of the GNU C library that include the NPTL threading library
c13182ef 684contain a wrapper function for
0bfa087b 685.BR getpid (2)
31830ef0 686that performs caching of PIDs.
c13182ef 687In programs linked against such libraries, calls to
0bfa087b 688.BR getpid (2)
31830ef0
MK
689may return the same value, even when the threads were not created using
690.B CLONE_THREAD
691(and thus are not in the same thread group).
692To get the truth, it may be necessary to use code such as the following
693.nf
694
695 #include <syscall.h>
696
697 pid_t mypid;
698
699 mypid = syscall(SYS_getpid);
700.fi
fea681da
MK
701.SH "SEE ALSO"
702.BR fork (2),
2b44301c 703.BR futex (2),
fea681da
MK
704.BR getpid (2),
705.BR gettid (2),
f2d0bbf1 706.BR set_thread_area (2),
2b44301c 707.BR set_tid_address (2),
f2d0bbf1 708.BR tkill (2),
5cc01e9c 709.BR unshare (2),
fea681da 710.BR wait (2),
3616b7c0
MK
711.BR capabilities (7),
712.BR pthreads (7)