proc_pid_task(5)
โจ proc_pid_task โ thread info, but make it make sense ๐
okay bestie, so this is from section 5 of the manual (file formats, iykyk) and it's literally all about how the kernel spills the tea on your threads. no cap, it's giving very "everything is a file" energy and honestly? iconic.
๐ฆ NAME ๐ฆ
/proc/pid/task/, /proc/tid/, /proc/thread-self/ โ all the thread information your heart could ever desire ๐
๐ธ DESCRIPTION ๐ธ
๐ /proc/pid/task/ (since Linux 2.6.0)
so this one is a directory, right? and inside it there's one little subdirectory for every single thread in the process. the name of each subdirectory is literally the numerical thread ID (tid) of that thread โ and if you wanna know more about how that number gets made, go peek at gettid(2). ๐ซถ
inside each of those subdirectories, there's a whole set of files with the same names and same contents as the ones under the /proc/pid directories. and here's the part that's lowkey important:
- for attributes that every thread shares, the contents of each file under the
task/tidsubdirectories will be the same as in the corresponding file in the parent/proc/piddirectory. for example: in a multithreaded process, all of thetask/tid/cwdfiles will have the same value as the/proc/pid/cwdfile in the parent directory, because every thread in a process shares one working directory. periodt. ๐ - but for attributes that are distinct per thread, the files under
task/tidmay have different values (like, say, the various fields in eachtask/tid/statusfile can differ from thread to thread), or honestly they might not exist in/proc/pidat all. ๐
โ ๏ธ heads up bestie: in a multithreaded process, the contents of the/proc/pid/taskdirectory are not available if the main thread has already terminated (typically by callingpthread_exit(3)). so likeโฆ don't go looking for them after that, because they're gone gone. ๐
also see:
๐ง /proc/tid/
there's a numerical subdirectory for each running thread that is not a thread group leader โ meaning a thread whose thread ID is not the same as its process ID. the subdirectory is named by the thread ID. each one of these subdirectories contains files and subdirectories exposing info about the thread with the thread ID tid, and the contents are the same as the corresponding /proc/pid/task/tid directories. same vibe, different address. โจ
now here's the sneaky part:
the/proc/tidsubdirectories are not visible when you iterate through/procwithgetdents(2)โ which means they're also not visible when you usels(1)to look at what's in/proc. like, they're hiding. ๐
however! the pathnames of these directories are visible to โ meaning usable as arguments in โ system calls that operate on pathnames. so they exist, they're just shy about it. main character energy tbqh. ๐
๐ /proc/thread-self/ (since Linux 3.17)
this directory refers to the thread accessing the /proc filesystem. it's identical to the /proc/self/task/tid directory named by the process thread ID (tid) of that same thread. so it's basically the "me, myself, and I" of threads. ๐
๐ SEE ALSO ๐
and that's the whole page, bestie โ you slayed it fr fr ๐โจ this was section 5 of the manual (file formats), straight out of Linux man-pages 6.20, dated 2026-02-08. go forth and inspect your threads, you gorgeous nerd ๐ฆ๐
๐ฆ where this page comes from
- arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- ๐ the page's license: GPL-3.0-or-later
- Copyright 1994-1995, Daniel Quinlan <Daniel.Quinlan@linux.org>
- Copyright 2002-2017, Michael Kerrisk <mtk.manpages@gmail.com>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms