Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it really needed on linux to recurse into /proc/[PID]/task/? #1341

Closed
GuillaumeGomez opened this issue Nov 29, 2023 · 3 comments
Closed
Labels
Linux 🐧 Linux related issues support request This is not a code issue but merely a support request. Please use the mailing list or IRC instead.

Comments

@GuillaumeGomez
Copy link
Contributor

From what I can see, all PIDs listed in the task subfolder are directly present in /proc, which means that the same information is retrieved twice unless I missed something. Is it really necessary to recurse into task then?

@BenBE
Copy link
Member

BenBE commented Nov 29, 2023

Yes.

That recursion into /proc/[PID]/task/ is done, as some (thread-specific) information are only available from there (pure pthreads don't show up in /proc, but only in the task directory). Also the main /proc does list processes and not POSIX threads.

To demonstrate, here's a quick screenshot:
image

The process belongs to a python script that both uses pthreads (visible on the right) as well as forked a sub-process (PID 211606 in that screenshot).

@BenBE BenBE added support request This is not a code issue but merely a support request. Please use the mailing list or IRC instead. Linux 🐧 Linux related issues labels Nov 29, 2023
@GuillaumeGomez
Copy link
Contributor Author

Thanks for the explanations!

@GuillaumeGomez
Copy link
Contributor Author

Interesting information I discovered in the man page:

The /proc/[tid] subdirectories are not visible when iterating through /proc with get‐
dents(2) (and thus are not visible when one uses ls(1) to view the contents of /proc).

So that definitely answers the question. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Linux 🐧 Linux related issues support request This is not a code issue but merely a support request. Please use the mailing list or IRC instead.
Projects
None yet
Development

No branches or pull requests

2 participants