-
Notifications
You must be signed in to change notification settings - Fork 241
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
Bikeshed: name for Socket::new_with_common_flags #111
Comments
We should use |
Hmm, I understand the reasoning behind this, but I do think that 9 out of 10 times (if not more) you want to use the default flags. So I would actually flip this: have |
This is probably true.
I still argue for keeping |
Hmm, another reason to be careful is that it will change the behavior of existing code. Currently, sockets are always created with the To me personally, it also feels wrong to create file descriptors without close-on-exec set by default. Leaking file descriptors is bad, so not a nice default. Also, currently there isn't even a way to set the close-on-exec flag after creation for the user. At the very least that should be exposed for the user, so |
The thing is, in some cases that is exactly what you want. We should support cases where the child process can use the socket. To me this library should do the least surprising thing. Since the documentation says the function says it corresponds to
|
Even then the proper thing to do is to disable the flag after forking, before exec-ing the new binary (or to use dup2, but still after forking). That's the only race-free way to let child processes inherit the file descriptor (atleast on platforms that have
Ah, I looked on docs.rs where it doesn't show up since it isn't released yet.
Another exception was And |
@de-vri-es what you propose as function name that only calls |
How about Or maybe flipped: |
Starting on implementing that suggestion in #117. |
Done in #134, new functions are called |
Pr #110 changed
Socket::new
to be a simple call tosocket(2)
, with setting common flags likeCLO_EXEC
. For convenience we should add back a function which copies the old behaviour. For that function we need a good name. Some possibilities:Socket::new_with_common_flags
: too long.Socket::like_std
: create a socket like the standard library would?The text was updated successfully, but these errors were encountered: