2 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
3 .\" <mtk.manpages@gmail.com>
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
7 .TH pthread_self 3 (date) "Linux man-pages (unreleased)"
9 pthread_self \- obtain ID of the calling thread
12 .RI ( libpthread ", " \-lpthread )
15 .B #include <pthread.h>
17 .B pthread_t pthread_self(void);
22 function returns the ID of the calling thread.
23 This is the same value that is returned in
26 .BR pthread_create (3)
27 call that created this thread.
29 This function always succeeds, returning the calling thread's ID.
31 This function always succeeds.
33 For an explanation of the terms used in this section, see
39 Interface Attribute Value
44 T} Thread safety MT-Safe
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
57 can't portably be compared using the C equality operator (\fB==\fP);
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
72 is not the same thing as the kernel thread ID returned by a call to
75 .BR pthread_create (3),
76 .BR pthread_equal (3),