README: Update links
[man-pages.git] / man3 / pthread_self.3
blob9aa58314dbb0e8e36ab8056e2ebd9796e26da773
1 '\" t
2 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
3 .\"     <mtk.manpages@gmail.com>
4 .\"
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\"
7 .TH pthread_self 3 (date) "Linux man-pages (unreleased)"
8 .SH NAME
9 pthread_self \- obtain ID of the calling thread
10 .SH LIBRARY
11 POSIX threads library
12 .RI ( libpthread ", " \-lpthread )
13 .SH SYNOPSIS
14 .nf
15 .B #include <pthread.h>
17 .B pthread_t pthread_self(void);
18 .fi
19 .SH DESCRIPTION
20 The
21 .BR pthread_self ()
22 function returns the ID of the calling thread.
23 This is the same value that is returned in
24 .I *thread
25 in the
26 .BR pthread_create (3)
27 call that created this thread.
28 .SH RETURN VALUE
29 This function always succeeds, returning the calling thread's ID.
30 .SH ERRORS
31 This function always succeeds.
32 .SH ATTRIBUTES
33 For an explanation of the terms used in this section, see
34 .BR attributes (7).
35 .TS
36 allbox;
37 lbx lb lb
38 l l l.
39 Interface       Attribute       Value
41 .na
42 .nh
43 .BR pthread_self ()
44 T}      Thread safety   MT-Safe
45 .TE
46 .SH STANDARDS
47 POSIX.1-2008.
48 .SH HISTORY
49 POSIX.1-2001.
50 .SH NOTES
51 POSIX.1 allows an implementation wide freedom in choosing
52 the type used to represent a thread ID;
53 for example, representation using either an arithmetic type or
54 a structure is permitted.
55 Therefore, variables of type
56 .I pthread_t
57 can't portably be compared using the C equality operator (\fB==\fP);
58 use
59 .BR pthread_equal (3)
60 instead.
62 Thread identifiers should be considered opaque:
63 any attempt to use a thread ID other than in pthreads calls
64 is nonportable and can lead to unspecified results.
66 Thread IDs are guaranteed to be unique only within a process.
67 A thread ID may be reused after a terminated thread has been joined,
68 or a detached thread has terminated.
70 The thread ID returned by
71 .BR pthread_self ()
72 is not the same thing as the kernel thread ID returned by a call to
73 .BR gettid (2).
74 .SH SEE ALSO
75 .BR pthread_create (3),
76 .BR pthread_equal (3),
77 .BR pthreads (7)