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
List threads per process #943
Comments
If this is something you'd be happy to accept, I can try to submit a PR. |
The big question is: is it possible to get this information on all sysinfo supported systems? If it's possible for mac, the code should be more or less the same for freebsd, and I assume linux shouldn't be too complicated either. But the big unknown is windows. :) |
It's already provided on Linux, the Line 85 in d9746a2
|
(Of course, the presumption that threads are the same as processes is kinda Linux-specific, so if you wanted a consistent thread information API it might look somewhat different. And e.g. scheduler status is definitely available on Linux and macOS, but not sure about FreeBSD and Windows...) |
If available on macOS, it'll be very likely available on freebsd as well. For windows, big unknown as usual. And yes, if we provide it for all systems, at this point we can directly provide a unified API for it. |
Getting the threads of a specific process is easy in Windows. You just call CreateToolhelp32Snapshot to get a snapshot handle, then you can enumerate the threads with Thread32First and Thread32Next. I have a working implementation in a library I never finished writing (the windows part works though, since that's what I actually needed) |
Thanks for a great package! I am currently trying to add macOS support to Linux-only application using it, and discovered it's not possible to get the threads for a process on macOS.
This is possible to do, e.g. here's a Python
psutil
example:The relevant code in
psutil
can be seen here: https://github.com/giampaolo/psutil/blob/bea3cf2d16899251b4b5f6b2609db9881645ea2d/psutil/_psutil_osx.c#L888The Python
psutil
library does not include some info that I would like (thread scheduler status) but I suspect that is still obtainable. In particular, thethread_basic_info
struct that it uses appears to have arun_state
flag, based on some googling (https://developer.apple.com/documentation/kernel/thread_basic_info_t). So it seems likesysinfo
could include much of the info it already includes for each thread on Linux.The text was updated successfully, but these errors were encountered: