CONTRIBUTING.d/patches: Please provide a git-range-diff(1)
[man-pages.git] / man5 / proc_pid_task.5
blob8081917759226a5b30490f7b99e54b5ee8491345
1 .\" Copyright (C) 1994, 1995, Daniel Quinlan <quinlan@yggdrasil.com>
2 .\" Copyright (C) 2002-2008, 2017, Michael Kerrisk <mtk.manpages@gmail.com>
3 .\" Copyright (C) 2023, Alejandro Colomar <alx@kernel.org>
4 .\"
5 .\" SPDX-License-Identifier: GPL-3.0-or-later
6 .\"
7 .TH proc_pid_task 5 (date) "Linux man-pages (unreleased)"
8 .SH NAME
9 /proc/pid/task/, /proc/tid/, /proc/thread\-self/ \- thread information
10 .SH DESCRIPTION
11 .TP
12 .IR /proc/ pid /task/ " (since Linux 2.6.0)"
13 .\" Precisely: Linux 2.6.0-test6
14 This is a directory that contains one subdirectory
15 for each thread in the process.
16 The name of each subdirectory is the numerical thread ID
17 .RI ( tid )
18 of the thread (see
19 .BR gettid (2)).
20 .IP
21 Within each of these subdirectories, there is a set of
22 files with the same names and contents as under the
23 .IR /proc/ pid
24 directories.
25 For attributes that are shared by all threads, the contents for
26 each of the files under the
27 .IR task/ tid
28 subdirectories will be the same as in the corresponding
29 file in the parent
30 .IR /proc/ pid
31 directory
32 (e.g., in a multithreaded process, all of the
33 .IR task/ tid /cwd
34 files will have the same value as the
35 .IR /proc/ pid /cwd
36 file in the parent directory, since all of the threads in a process
37 share a working directory).
38 For attributes that are distinct for each thread,
39 the corresponding files under
40 .IR task/ tid
41 may have different values (e.g., various fields in each of the
42 .IR task/ tid /status
43 files may be different for each thread),
44 .\" in particular: "children" :/
45 or they might not exist in
46 .IR /proc/ pid
47 at all.
48 .IP
49 .\" The following was still true as at kernel 2.6.13
50 In a multithreaded process, the contents of the
51 .IR /proc/ pid /task
52 directory are not available if the main thread has already terminated
53 (typically by calling
54 .BR pthread_exit (3)).
55 .TP
56 .IR /proc/ tid /
57 There  is a numerical subdirectory for each running thread
58 that is not a thread group leader
59 (i.e., a thread whose thread ID is not the same as its process ID);
60 the subdirectory is named by the thread ID.
61 Each one of these subdirectories contains files and subdirectories
62 exposing information about the thread with the thread ID
63 .IR tid .
64 The contents of these directories are the same as the corresponding
65 .IR /proc/ pid /task/ tid
66 directories.
67 .IP
68 The
69 .IR /proc/ tid
70 subdirectories are
71 .I not
72 visible when iterating through
73 .I /proc
74 with
75 .BR getdents (2)
76 (and thus are
77 .I not
78 visible when one uses
79 .BR ls (1)
80 to view the contents of
81 .IR /proc ).
82 However, the pathnames of these directories are visible to
83 (i.e., usable as arguments in)
84 system calls that operate on pathnames.
85 .TP
86 .IR /proc/thread\-self/ " (since Linux 3.17)"
87 .\" commit 0097875bd41528922fb3bb5f348c53f17e00e2fd
88 This directory refers to the thread accessing the
89 .I /proc
90 filesystem,
91 and is identical to the
92 .IR /proc/self/task/ tid
93 directory named by the process thread ID
94 .RI ( tid )
95 of the same thread.
96 .SH SEE ALSO
97 .BR proc (5)