shirou / gopsutil

psutil for golang
Other
10.66k stars 1.59k forks source link

implement process:NumFDs for Windows #1712

Closed al-online closed 2 months ago

al-online commented 2 months ago

I found that gopsutil does not have a method to get the number of handles for a process, so I implemented it myself and would like to submit a pull request.

shirou commented 2 months ago

I have confirmed that it works on my Windows machine, and it seems to be functioning correctly. Thank you.

However, file descriptors (FD) on Unix-like systems and handles on Windows are not exactly the same. Because of this, psutil provides a separate function called num_handles().

It would be possible for gopsutil to prepare a platform-specific struct like ExWindows, but that would add complexity.

The differences between FDs and handles are not that significant, so it seems like we just need to be mindful of how they are used. Therefore, how about adding a comment like, "On Windows, this returns the number of handles, not number of FDs" on the NumFDsWithContext in process_windows.go?

al-online commented 2 months ago

Sure, this clarification is indeed necessary, and I am willing to add the comment!