rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.01k stars 12.68k forks source link

TcpSocket try_clone() sets close-on-exec but this isn't documented #47946

Open setharnold opened 6 years ago

setharnold commented 6 years ago

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:

Thanks

frewsxcv commented 6 years ago

@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?

alexcrichton commented 6 years ago

@frewsxcv ah yeah every file descriptor libstd creates has CLOEXEC, so this should be good to document

frewsxcv commented 6 years ago

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 behavior to each of these APIs mentioning which platforms set CLOEXEC?

steveklabnik commented 6 years ago

@frewsxcv yup!