Skip to content

implement process:NumFDs for Windows - #1712

Merged
shirou merged 2 commits into
shirou:masterfrom
al-online:numfds_for_windows
Sep 24, 2024
Merged

implement process:NumFDs for Windows#1712
shirou merged 2 commits into
shirou:masterfrom
al-online:numfds_for_windows

Conversation

@al-online

Copy link
Copy Markdown
Contributor

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

shirou commented Sep 23, 2024

Copy link
Copy Markdown
Owner

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

Copy link
Copy Markdown
Contributor Author

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

@shirou shirou left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the update and your great contribution!

@shirou
shirou merged commit fdc3c05 into shirou:master Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants