]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/set_tid_address.2
intro.1, _exit.2, access.2, alarm.2, alloc_hugepages.2, arch_prctl.2, bind.2, chdir...
[thirdparty/man-pages.git] / man2 / set_tid_address.2
CommitLineData
fea681da
MK
1.\" Copyright (C) 2004 Andries Brouwer (aeb@cwi.nl)
2.\"
4b72fb64 3.\" %%%LICENSE_START(verbatim)
fea681da
MK
4.\" Permission is granted to make and distribute verbatim copies of this
5.\" manual provided the copyright notice and this permission notice are
6.\" preserved on all copies.
7.\"
8.\" Permission is granted to copy and distribute modified versions of this
9.\" manual under the conditions for verbatim copying, provided that the
10.\" entire resulting derived work is distributed under the terms of a
11.\" permission notice identical to this one.
c13182ef 12.\"
fea681da
MK
13.\" Since the Linux kernel and libraries are constantly changing, this
14.\" manual page may be incorrect or out-of-date. The author(s) assume no
15.\" responsibility for errors or omissions, or for damages resulting from
16.\" the use of the information contained herein. The author(s) may not
17.\" have taken the same level of care in the production of this manual,
18.\" which is licensed free of charge, as they might when working
19.\" professionally.
c13182ef 20.\"
fea681da
MK
21.\" Formatted or processed versions of this manual, if unaccompanied by
22.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 23.\" %%%LICENSE_END
fea681da 24.\"
f5fe5952 25.TH SET_TID_ADDRESS 2 2012-07-19 "Linux" "Linux Programmer's Manual"
fea681da
MK
26.SH NAME
27set_tid_address \- set pointer to thread ID
28.SH SYNOPSIS
29.nf
30.B #include <linux/unistd.h>
31.sp
32.BI "long set_tid_address(int *" tidptr );
c8250206 33.fi
fea681da 34.SH DESCRIPTION
72442c68 35For each process, the kernel maintains two attributes (addresses) called
fea681da
MK
36.I set_child_tid
37and
72442c68
MK
38.IR clear_child_tid .
39These two attributes contain the value NULL by default.
568c4c02
MK
40.TP
41.I set_child_tid
fea681da
MK
42If a process is started using
43.BR clone (2)
44with the
45.B CLONE_CHILD_SETTID
46flag,
47.I set_child_tid
f5fe5952
MK
48is set to the value passed in the
49.I ctid
50argument of that system call.
568c4c02 51.IP
fea681da
MK
52When
53.I set_child_tid
54is set, the very first thing the new process does
55is writing its PID at this address.
568c4c02
MK
56.TP
57.I clear_child_tid
fea681da
MK
58If a process is started using
59.BR clone (2)
60with the
61.B CLONE_CHILD_CLEARTID
c13182ef 62flag,
fea681da 63.I clear_child_tid
f5fe5952
MK
64is set to the value passed in the
65.I ctid
66argument of that system call.
fea681da
MK
67.LP
68The system call
e511ffb6 69.BR set_tid_address ()
fea681da
MK
70sets the
71.I clear_child_tid
72value for the calling process to
73.IR tidptr .
74.LP
4e9ee225
MK
75When a process whose
76.I clear_child_tid
77is not NULL terminates, then,
78if the process is sharing memory with other processes or threads,
79then 0 is written at the address specified in
fea681da 80.I clear_child_tid
4e9ee225
MK
81and the kernel performs the following operation:
82
83 futex(clear_child_tid, FUTEX_WAKE, 1, NULL, NULL, 0);
84
85The effect of this operation is to wake a single process that
86is performing a futex wait on the memory location.
87Errors from the futex wake operation are ignored.
47297adb 88.SH RETURN VALUE
e511ffb6 89.BR set_tid_address ()
08b7e584 90always returns the PID of the calling process.
bd0a01ce
MK
91.SH ERRORS
92.BR set_tid_address ()
93always succeeds.
889829be 94.SH VERSIONS
fea681da
MK
95This call is present since Linux 2.5.48.
96Details as given here are valid since Linux 2.5.49.
47297adb 97.SH CONFORMING TO
8382f16d 98This system call is Linux-specific.
47297adb 99.SH SEE ALSO
fea681da
MK
100.BR clone (2),
101.BR futex (2)