diff options
Diffstat (limited to 'man/man2/gettid.2')
-rw-r--r-- | man/man2/gettid.2 | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/man/man2/gettid.2 b/man/man2/gettid.2 new file mode 100644 index 0000000..fa1fb2c --- /dev/null +++ b/man/man2/gettid.2 @@ -0,0 +1,74 @@ +.\" Copyright 2003 Abhijit Menon-Sen <ams@wiw.org> +.\" and Copyright (C) 2008 Michael Kerrisk <mtk.manpages@gmail.com> +.\" +.\" SPDX-License-Identifier: Linux-man-pages-copyleft +.\" +.TH gettid 2 2024-05-02 "Linux man-pages (unreleased)" +.SH NAME +gettid \- get thread identification +.SH LIBRARY +Standard C library +.RI ( libc ", " \-lc ) +.SH SYNOPSIS +.nf +.B #define _GNU_SOURCE +.B #include <unistd.h> +.P +.B pid_t gettid(void); +.fi +.SH DESCRIPTION +.BR 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 +.BR getpid (2)). +In a multithreaded process, all threads +have the same PID, but each one has a unique TID. +For further details, see the discussion of +.B CLONE_THREAD +in +.BR clone (2). +.SH RETURN VALUE +On success, returns the thread ID of the calling thread. +.SH ERRORS +This call is always successful. +.SH STANDARDS +Linux. +.SH HISTORY +Linux 2.4.11, +glibc 2.30. +.SH 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 +.BR pthread_self (3)). +.P +In a new thread group created by a +.BR clone (2) +call that does not specify the +.B CLONE_THREAD +flag (or, equivalently, a new process created by +.BR fork (2)), +the new process is a thread group leader, +and its thread group ID (the value returned by +.BR getpid (2)) +is the same as its thread ID (the value returned by +.BR gettid ()). +.SH SEE ALSO +.BR capget (2), +.BR clone (2), +.BR fcntl (2), +.BR fork (2), +.BR get_robust_list (2), +.BR getpid (2), +.\" .BR kcmp (2), +.BR ioprio_set (2), +.\" .BR move_pages (2), +.\" .BR migrate_pages (2), +.BR perf_event_open (2), +.\" .BR process_vm_readv (2), +.\" .BR ptrace (2), +.BR sched_setaffinity (2), +.BR sched_setparam (2), +.BR sched_setscheduler (2), +.BR tgkill (2), +.BR timer_create (2) |