GuillaumeGomez / sysinfo

Cross-platform library to fetch system information
MIT License
2.19k stars 320 forks source link

Does system::processes_by_exact_name() return all threads on Linux? #1323

Closed andrewdavidmackenzie closed 4 months ago

andrewdavidmackenzie commented 4 months ago

I'm using sysinfo to detect any other running instance of my binary ("piglet"), across MacOS, Windows, Linux and Pi OS.

On Mac so far it has worked a treat, now I'm debugging it on Linux (PiOS) using VSCode.

I have no prior running instances of this binary (just rebooted also), and when I call processes_by_exact_name() to detect any possible other instances, it returns 4 to me.

Is it possible it's returning one for each thread? Also, the "pid" reported for each one seems to match the "tid" reported by VSCode...

This is a tokio async app, and VSCode shows 4 threads with different task Ids, all with the same name:

Screenshot 2024-07-24 at 5 21 08 PM
andrewdavidmackenzie commented 4 months ago

Looks like that is so, and I will have to filter out the threads, using https://docs.rs/sysinfo/latest/sysinfo/struct.Process.html#method.thread_kind ?