-
Notifications
You must be signed in to change notification settings - Fork 691
doc(socket): add a note on how to enable NONBLOCK / CLOEXEC on macOS #2619
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The variant is not available on macOS, so macOS users won't see this hint when reading Nix's doc.
BTW, do we really need to document this? Googling "set file descriptor non-blocking" directly leads me to this: https://stackoverflow.com/questions/27266346/how-to-set-file-descriptor-non-blocking
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.
My story with that is: I don't use macOS, but people on my team do, so when I was using this API the issue came up that this flag won't compile for everyone and together with that the false assumption, that macOS (or maybe just
nix
) doesn't supportNONBLOCK
.My searches on the macOS support gave some arguments that it actually exists (at this point my understanding was it's just
nix
's shortcoming). Unfortunately only much later after going through comments on this PR (#863) I realized it's just a difference in macOS and linux API, not the complete lack of support.Given that - the usecase of linux developer looking up on how to enable feature on macOS would be much better served having the doc comments somewhere around even if macOS developer has those flags hidden. And in any case, it's still shown on https://docs.rs/nix/latest/nix/sys/socket/struct.SockFlag.html#associatedconstant.SOCK_NONBLOCK
Not completely fair - this search is for the actual solution, not the problem, so surely it yields good answer. The real question "does macOS support NONBLOCK and why nix crate doesn't expose it" is a bit harder to answer.
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 do get what you said here, but Nix should not do such cross-platform documentation, I do not remember such things ever happened since I maintained this lib.
Regarding Nix's documentation, we try to be well-documented, but platform's man pages are the right place that you should refer to when figuring out something,
$ man 2 socket
. And if you believe what Apple man pages say,SOCK_NONBLOCK
is a symbol that macOS does not provide. (I say so because Apple man pages are usually outdated, you need to search darwin's source code if you wanna do serious research)I think I will document why Nix's
socket()
function has an extraflags
argument, this can confuse users when they read the doc.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.
Yap, those are valid points. From the perspective of
nix
user I think some hint on "why" specific flag variants are selectively available only on some platforms would be useful, but as you say it might belong to the level of flags enum or somewhere else.