Skip to content

Taking RawFd by value is not sound #594

Open
@kamalmarhubi

Description

@kamalmarhubi

Raised by @lucab on #562

I think these all do an implicit copy+own of the RawFd (as it is just an alias to an int), and I fear this doesn't really guarantee that the fd has not been closed/dropped in the meanwhile by a close().

This is a problem. A RawFd value may be kept long enough to end up referring to a different file. We may wish to provide a non-copy wrapper type similar to mio's EventedFd that allows enforcing the borrowing relationship. From the docs:

Note that EventedFd takes a &RawFd. This is because EventedFd does not take ownership of the FD. Specifically, it will not manage any lifecycle related operations, such as closing the FD on drop.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions