I have process id 1234. This process contains thread id 1235.
When I use ls -l /proc
I see only the pid (1234) but when I open the thread status file using cat /proc/1235/status
I can see data.
Why is that?
Can I access with C code directly with tid? /proc/1235/mem
without knowing the process id?
Best Answer
Yes,
/proc
“contains” directory entries for thread identifiers as well as process identifiers, but only the latter are enumerated bygetdents
, sols
only shows process identifiers. This is described inman 5 proc
, in the “Overview” section, since release 5.00 of the man-pages project:I suspect it’s to preserve backwards-compatibility (for programs written before threads existed in their current form on Linux), and to limit scalability problems.
Yes, if you know the tid you can access
/proc/${tid}
directly, without going through the pid.