]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/gettid.2
user_namespaces.7: Minor rewordings of recently added text
[thirdparty/man-pages.git] / man2 / gettid.2
CommitLineData
fea681da 1.\" Copyright 2003 Abhijit Menon-Sen <ams@wiw.org>
fd484056
MK
2.\" and Copyright (C) 2008 Michael Kerrisk <mtk.manpages@gmail.com>
3.\"
93015253 4.\" %%%LICENSE_START(VERBATIM)
fea681da
MK
5.\" Permission is granted to make and distribute verbatim copies of this
6.\" manual provided the copyright notice and this permission notice are
7.\" preserved on all copies.
8.\"
9.\" Permission is granted to copy and distribute modified versions of this
10.\" manual under the conditions for verbatim copying, provided that the
11.\" entire resulting derived work is distributed under the terms of a
12.\" permission notice identical to this one.
c13182ef 13.\"
fea681da
MK
14.\" Since the Linux kernel and libraries are constantly changing, this
15.\" manual page may be incorrect or out-of-date. The author(s) assume no
16.\" responsibility for errors or omissions, or for damages resulting from
17.\" the use of the information contained herein. The author(s) may not
18.\" have taken the same level of care in the production of this manual,
19.\" which is licensed free of charge, as they might when working
20.\" professionally.
c13182ef 21.\"
fea681da
MK
22.\" Formatted or processed versions of this manual, if unaccompanied by
23.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 24.\" %%%LICENSE_END
fea681da 25.\"
9ba01802 26.TH GETTID 2 2019-03-06 "Linux" "Linux Programmer's Manual"
fea681da
MK
27.SH NAME
28gettid \- get thread identification
29.SH SYNOPSIS
16718a1c 30.nf
fea681da 31.B #include <sys/types.h>
68e4db0a 32.PP
fea681da 33.B pid_t gettid(void);
c12fd10d 34.fi
fea681da 35.SH DESCRIPTION
60a90ecd 36.BR gettid ()
fd484056
MK
37returns the caller's thread ID (TID).
38In a single-threaded process, the thread ID
39is equal to the process ID (PID, as returned by
40.BR getpid (2)).
41In a multithreaded process, all threads
fea681da 42have the same PID, but each one has a unique TID.
fd484056
MK
43For further details, see the discussion of
44.BR CLONE_THREAD
45in
46.BR clone (2).
47297adb 47.SH RETURN VALUE
56d898aa 48On success, returns the thread ID of the calling thread.
fea681da
MK
49.SH ERRORS
50This call is always successful.
12afd1b4
MK
51.SH VERSIONS
52The
53.BR gettid ()
54system call first appeared on Linux in kernel 2.4.11.
ed474f00
MK
55Library support was added in glibc 2.30.
56(Earlier glibc versions did not provide a wrapper for this system call,
57.\" FIXME . See http://sourceware.org/bugzilla/show_bug.cgi?id=6399
58.\" "gettid() should have a wrapper"
59necessitating the use of
60.BR syscall (2).)
47297adb 61.SH CONFORMING TO
60a90ecd 62.BR gettid ()
8382f16d 63is Linux-specific and should not be used in programs that
fea681da 64are intended to be portable.
c12fd10d 65.SH NOTES
fd484056
MK
66The thread ID returned by this call is not the same thing as a
67POSIX thread ID (i.e., the opaque value returned by
68.BR pthread_self (3)).
efeece04 69.PP
4a8f7185
MK
70In a new thread group created by a
71.BR clone (2)
72call that does not specify the
73.BR CLONE_THREAD
74flag (or, equivalently, a new process created by
75.BR fork (2)),
76the new process is a thread group leader,
77and its thread group ID (the value returned by
b3eb2280 78.BR getpid (2))
4a8f7185
MK
79is the same as its thread ID (the value returned by
80.BR gettid ()).
47297adb 81.SH SEE ALSO
76006a4a 82.BR capget (2),
fea681da 83.BR clone (2),
76006a4a 84.BR fcntl (2),
fea681da 85.BR fork (2),
c9269da6 86.BR getpid (2),
76006a4a 87.BR get_robust_list (2),
76006a4a
MK
88.\" .BR kcmp (2),
89.BR ioprio_set (2),
90.\" .BR move_pages (2),
91.\" .BR migrate_pages (2),
92.BR perf_event_open (2),
93.\" .BR process_vm_readv (2),
94.\" .BR ptrace (2),
95.BR sched_setaffinity (2),
96.BR sched_setparam (2),
97.BR sched_setscheduler (2),
0ec954ee
MK
98.BR tgkill (2),
99.BR timer_create (2)