How can I get the number of threads running in a process from /proc/[pid]/stat in Linux?
I have the pid of the process. I would like to know the current number of thread running in the process. I know I can read /proc/pid/stat for this information, but I'm not sure how to specifically get the number of threads from stat. Can anyone help?
Thanks!
The number of entries in /proc/pid/task
is the number of threads in the process. Also, /proc/pid/status
has a Threads
line. In /proc/pid/stat
, it's the 20th field.