TcpSocket try_clone() sets close-on-exec but this isn't documented
Hello, the TcpSocket try_clone() method calls into .duplicate(), which sets the close-on-exec flag on the socket:
https://doc.rust-lang.org/src/std/net/tcp.rs.html#255-257 https://github.com/rust-lang/rust/blob/master/src/libstd/sys/unix/fd.rs#L197
I believe the documentation for try_clone() should be extended to describe:
- That this is an operation with the underlying operating system, dup() or WSADuplicateSocket() or whatever is appropriate (this would help address very similar issue 45536)
- That the duplication operation also sets the close-on-exec flag.
Thanks
Hello, the TcpSocket try_clone() method calls into .duplicate(), which sets the close-on-exec flag on the socket:
https://doc.rust-lang.org/src/std/net/tcp.rs.html#255-257 https://github.com/rust-lang/rust/blob/master/src/libstd/sys/unix/fd.rs#L197
I believe the documentation for try_clone() should be extended to describe:
- That this is an operation with the underlying operating system, dup() or WSADuplicateSocket() or whatever is appropriate ~~(this would help address very similar issue 45536)~~
- That the duplication operation also sets the close-on-exec flag.
Thanks
<!-- TRIAGEBOT_START --> <!-- TRIAGEBOT_ASSIGN_START --> <!-- TRIAGEBOT_ASSIGN_DATA_START$${"user":"HypheX"}$$TRIAGEBOT_ASSIGN_DATA_END --> <!-- TRIAGEBOT_ASSIGN_END --> <!-- TRIAGEBOT_END -->Dylan DPC at 2024-05-14 05:18:23
@rust-lang/libs checking with y'all before a PR gets opened for this – is it okay to specify that close-on-exec flag (CLOEXEC) gets set as a platform-specific behavior for
TcpStream::try_clone?Corey Farwell at 2018-02-11 18:00:36
@frewsxcv ah yeah every file descriptor libstd creates has CLOEXEC, so this should be good to document
Alex Crichton at 2018-02-11 18:45:12
so next step here is deciding how to document this. i imagine there are a bunch of APIs in the standard library that create file descriptors. would it be excessive to add a
# Platform-specific behaviorto each of these APIs mentioning which platforms setCLOEXEC?Corey Farwell at 2018-03-27 12:54:55
@frewsxcv yup!
Steve Klabnik at 2018-05-29 08:57:54
@rustbot claim
Lisa FS at 2024-12-07 05:41:11