---
name: "gettid"
section: "2"
platform: "linux"
package: "man-pages"
version: "6.19-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/gettid"
---

# gettid(2)

get thread identification

## NAME

gettid - get thread identification

## LIBRARY

Standard C library (*libc*, *-lc*)

## SYNOPSIS

```
#define _GNU_SOURCE
#include <unistd.h>
```

**pid\_t gettid(void);**

## DESCRIPTION

**gettid**() returns the caller's thread ID (TID). In a single-threaded process, the thread ID is equal to the process ID (PID, as returned by [**getpid**(2)](/getpid/2.md)). In a multithreaded process, all threads have the same PID, but each one has a unique TID. For further details, see the discussion of **CLONE\_THREAD** in [**clone**(2)](/clone/2.md).

## RETURN VALUE

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

## ERRORS

This call is always successful.

## STANDARDS

Linux.

## HISTORY

Linux 2.4.11, glibc 2.30.

## NOTES

The thread ID returned by this call is not the same thing as a POSIX thread ID (i.e., the opaque value returned by [**pthread\_self**(3)](/pthread_self/3.md)).

In a new thread group created by a [**clone**(2)](/clone/2.md) call that does not specify the **CLONE\_THREAD** flag (or, equivalently, a new process created by [**fork**(2)](/fork/2.md)), the new process is a thread group leader, and its thread group ID (the value returned by [**getpid**(2)](/getpid/2.md)) is the same as its thread ID (the value returned by **gettid**()).

## SEE ALSO

[**capget**(2)](/capget/2.md), [**clone**(2)](/clone/2.md), [**fcntl**(2)](/fcntl/2.md), [**fork**(2)](/fork/2.md), [**get\_robust\_list**(2)](/get_robust_list/2.md), [**getpid**(2)](/getpid/2.md), [**ioprio\_set**(2)](/ioprio_set/2.md), [**perf\_event\_open**(2)](/perf_event_open/2.md), [**sched\_setaffinity**(2)](/sched_setaffinity/2.md), [**sched\_setparam**(2)](/sched_setparam/2.md), [**sched\_setscheduler**(2)](/sched_setscheduler/2.md), [**tgkill**(2)](/tgkill/2.md), [**timer\_create**(2)](/timer_create/2.md)
