Skip to content

Add NumFDs implementation for Darwin#1965

Merged
shirou merged 3 commits intoshirou:masterfrom
kerlenton:darwin-numfds
Dec 13, 2025
Merged

Add NumFDs implementation for Darwin#1965
shirou merged 3 commits intoshirou:masterfrom
kerlenton:darwin-numfds

Conversation

@kerlenton
Copy link
Copy Markdown
Contributor

@kerlenton kerlenton commented Dec 10, 2025

Implements NumFDs() for macOS using the proc_pidinfo syscall with PROC_PIDLISTFDS.

Changes

  • Added NumFDsWithContext() implementation for Darwin in process_darwin.go
  • Uses two-stage syscall pattern (standard for macOS APIs):
    1. First call gets required buffer size
    2. Second call retrieves actual FD list
  • Added PROC_PIDLISTFDS constant to common_darwin.go
  • Moved NumFDsWithContext stub from process_bsd.go to OS-specific files
  • Added tests following existing test patterns

Testing

  • Tests pass on macOS
  • Correctly counts file descriptors
  • Handles non-existent processes

Copy link
Copy Markdown
Owner

@shirou shirou left a comment

Choose a reason for hiding this comment

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

Looks great overall! Thank you for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants