Skip to content

Conversation

@AprilNEA
Copy link
Contributor

@AprilNEA AprilNEA commented Jan 17, 2026

Document that try_clone() sets the close-on-exec flag on duplicated sockets, addressing issue #47946.

On Unix, F_DUPFD_CLOEXEC is used to atomically duplicate the file descriptor with the close-on-exec flag set. On Windows, the duplicated socket is created without HANDLE_FLAG_INHERIT.

This affects:

  • TcpStream::try_clone()
  • TcpListener::try_clone()
  • UdpSocket::try_clone()
  • UnixStream::try_clone()
  • UnixListener::try_clone()
  • UnixDatagram::try_clone()

r? @joshtriplett

Document that `try_clone()` sets the close-on-exec flag on duplicated
sockets, addressing issue rust-lang#47946.

On Unix, `F_DUPFD_CLOEXEC` is used to atomically duplicate the file
descriptor with the close-on-exec flag set. On Windows, the duplicated
socket is created without `HANDLE_FLAG_INHERIT`.

This affects:
- `TcpStream::try_clone()`
- `TcpListener::try_clone()`
- `UdpSocket::try_clone()`
- `UnixStream::try_clone()`
- `UnixListener::try_clone()`
- `UnixDatagram::try_clone()`
@rustbot rustbot added O-unix Operating system: Unix-like S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jan 17, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 17, 2026

joshtriplett is not on the review rotation at the moment.
They may take a while to respond.

@rustbot
Copy link
Collaborator

rustbot commented Jan 17, 2026

⚠️ Warning ⚠️

  • There are issue links (such as #123) in the commit messages of the following commits.
    Please move them to the PR description, to avoid spamming the issues with references to the commit, and so this bot can automatically canonicalize them to avoid issues with subtree.

@AprilNEA
Copy link
Contributor Author

⚠️ Warning ⚠️

  • There are issue links (such as #123) in the commit messages of the following commits.
    Please move them to the PR description, to avoid spamming the issues with references to the commit, and so this bot can automatically canonicalize them to avoid issues with subtree.

Solved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

O-unix Operating system: Unix-like S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants