-
Notifications
You must be signed in to change notification settings - Fork 1.2k
don't rely on getdtablesize() #2586
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
Conversation
@swift-ci please test |
1 similar comment
@swift-ci please test |
@swift-ci please test |
@swift-ci please test |
Android and possibly other UNIX systems lack getdtablesize() so let's try to use a better way of estimating the file descriptors we need to close post-fork, pre-exec by listing /proc/self/fd. If that fails, we fall back on getdtablesize or as a last resort a hard-coded 4096.
@swift-ci please test |
} | ||
|
||
return highestFDSoFar | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would
return try? FileManager.default.contentsOfDirectory(atPath: "/proc/self/fd").compactMap { CInt($0) }.max()
be a bit simpler?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@spevans I wasn't sure about the guarantees around symlinks as in does it follow symlinks, does it not, what happens if the symlink is a broken link, etc. Therefore I went for readdir
, happy to change if we think it's fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like @spevans' suggestion, but, lets get this merged to repair the build, and we can do that in a follow up.
Android and possibly other UNIX systems lack getdtablesize() so let's
try to use a better way of estimating the file descriptors we need to
close post-fork, pre-exec by listing /proc/self/fd. If that fails, we
fall back on getdtablesize or as a last resort a hard-coded 4096.