1gettid(2)                     System Calls Manual                    gettid(2)
2
3
4

NAME

6       gettid - get thread identification
7

LIBRARY

9       Standard C library (libc, -lc)
10

SYNOPSIS

12       #define _GNU_SOURCE
13       #include <unistd.h>
14
15       pid_t gettid(void);
16

DESCRIPTION

18       gettid()  returns  the  caller's thread ID (TID).  In a single-threaded
19       process, the thread ID is equal to the process ID (PID, as returned  by
20       getpid(2)).  In a multithreaded process, all threads have the same PID,
21       but each one has a unique TID.  For further details, see the discussion
22       of CLONE_THREAD in clone(2).
23

RETURN VALUE

25       On success, returns the thread ID of the calling thread.
26

ERRORS

28       This call is always successful.
29

STANDARDS

31       Linux.
32

HISTORY

34       Linux 2.4.11, glibc 2.30.
35

NOTES

37       The  thread  ID  returned by this call is not the same thing as a POSIX
38       thread ID (i.e., the opaque value returned by pthread_self(3)).
39
40       In a new thread group created by a clone(2) call that does not  specify
41       the  CLONE_THREAD  flag  (or,  equivalently,  a  new process created by
42       fork(2)), the new process is a thread  group  leader,  and  its  thread
43       group ID (the value returned by getpid(2)) is the same as its thread ID
44       (the value returned by gettid()).
45

SEE ALSO

47       capget(2), clone(2), fcntl(2), fork(2), get_robust_list(2),  getpid(2),
48       ioprio_set(2),   perf_event_open(2),  sched_setaffinity(2),  sched_set‐
49       param(2), sched_setscheduler(2), tgkill(2), timer_create(2)
50
51
52
53Linux man-pages 6.05              2023-03-30                         gettid(2)
Impressum