3 ms·
File Descriptors are not files. They are unique per process so the rust compiler should be able to completely track their ownership.
by voxic11 5y ago
File Descriptors are not files. They are unique per process so the rust compiler should be able to completely track their ownership.
- hn_go_brrrrr 5y agoNo they're not. Other processes can pass you an fd at startup, you can send/receive fds across a Unix domain socket, and there are even syscalls for copying another process's fds.
- estebank 5y agoBut another process wouldn't be passing an OwnedFd in that case, and sending an OwnedFd away would pass the underlying FD and drop the wrapping OwnedFd. The process receiving the FD would have to take care (as today in any C program) to determine whether they are responsible dispose of the FD or not.
- brandmeyer 5y agoThe receiving process gets a copy of the file descriptor. Both processes must close(2) it.