1PTHREAD_SELF(3)            Linux Programmer's Manual           PTHREAD_SELF(3)
2
3
4

NAME

6       pthread_self - obtain ID of the calling thread
7

SYNOPSIS

9       #include <pthread.h>
10
11       pthread_t pthread_self(void);
12
13       Compile and link with -pthread.
14

DESCRIPTION

16       The pthread_self() function returns the ID of the calling thread.  This
17       is the same value that is returned in *thread in the  pthread_create(3)
18       call that created this thread.
19

RETURN VALUE

21       This function always succeeds, returning the calling thread's ID.
22

ERRORS

24       This function always succeeds.
25

ATTRIBUTES

27       For   an   explanation   of   the  terms  used  in  this  section,  see
28       attributes(7).
29
30       ┌───────────────┬───────────────┬─────────┐
31Interface      Attribute     Value   
32       ├───────────────┼───────────────┼─────────┤
33pthread_self() │ Thread safety │ MT-Safe │
34       └───────────────┴───────────────┴─────────┘

CONFORMING TO

36       POSIX.1-2001, POSIX.1-2008.
37

NOTES

39       POSIX.1 allows an implementation wide freedom in choosing the type used
40       to  represent  a thread ID; for example, representation using either an
41       arithmetic type or a structure is permitted.  Therefore,  variables  of
42       type pthread_t can't portably be compared using the C equality operator
43       (==); use pthread_equal(3) instead.
44
45       Thread identifiers should be considered opaque: any attempt  to  use  a
46       thread  ID  other than in pthreads calls is nonportable and can lead to
47       unspecified results.
48
49       Thread IDs are guaranteed to be unique only within a process.  A thread
50       ID  may  be  reused  after  a  terminated  thread has been joined, or a
51       detached thread has terminated.
52
53       The thread ID returned by pthread_self() is not the same thing  as  the
54       kernel thread ID returned by a call to gettid(2).
55

SEE ALSO

57       pthread_create(3), pthread_equal(3), pthreads(7)
58

COLOPHON

60       This  page  is  part of release 4.15 of the Linux man-pages project.  A
61       description of the project, information about reporting bugs,  and  the
62       latest     version     of     this    page,    can    be    found    at
63       https://www.kernel.org/doc/man-pages/.
64
65
66
67Linux                             2017-09-15                   PTHREAD_SELF(3)
Impressum