Open
Description
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 becauseEventedFd
does not take ownership of the FD. Specifically, it will not manage any lifecycle related operations, such as closing the FD on drop.