uds icon indicating copy to clipboard operation
uds copied to clipboard

Change recv_fds to use OwnedFd instead of RawFd

Open rukai opened this issue 3 months ago • 0 comments

From my reading of from_raw_fd and the IO safety rules we should be able to change UnixSeqPacketConn::recv_fds to return an OwnedFd instead of RawFd.

The IO safety rules specifically calls out: "Note that exclusive ownership of a file descriptor does not imply exclusive ownership of the underlying kernel object that the file descriptor references". And when using SCM_RIGHTS ancillary data, the kernel assigns the receiving process a new FD pointing to the same kernel object as the original processes FD.

Making this change would allow users to make use of the received FDs without needing to call unsafe functions.

I am happy to provide a PR if you agree with this change?

rukai avatar Sep 23 '25 01:09 rukai