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/tid subdirectories will be the same as in the corresponding file in the parent /proc/pid directory. for example: in a multithreaded process, all of the task/tid/cwd files will have the same value as the /proc/pid/cwd file 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/tid may have different values (like, say, the various fields in each task/tid/status file can differ from thread to thread), or honestly they might not exist in /proc/pid at all. ๐Ÿ™ˆ
โš ๏ธ heads up bestie: in a multithreaded process, the contents of the /proc/pid/task directory are not available if the main thread has already terminated (typically by calling pthread_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/tid subdirectories are not visible when you iterate through /proc with getdents(2) โ€” which means they're also not visible when you use ls(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
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms