-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change
dup2
's second operand from &OwnedFd
to &mut OwnedFd
.
And similar for `dup3`. The idea behind using `&OwnedFd` is that `dup2`'s second operand isn't like a normal borrow. It effectively closes the old file descriptor, and creates a new one with the same index. This could break assumptions of classes that have an `AsFd` to allow users to do special I/O operations, but which don't expect users can close and reopen their file descriptor as some completely unrelated resource. However, the existence of things like [`FilelikeView`], as well as the `ManuallyDrop` pattern, mean that `&OwnedFd` doesn't actually prevent users from using `dup2` on a `BorrowedFd`. With sunfishcode/io-lifetimes#32 though, `&mut OwnedFd` would be sufficient, because it removes the `DerefMut` implementation. So change `rustix` stance to be that `dup2` requires `&mut OwnedFd`. This means that it's no longer possible to pass the same file descriptor to both operands of `dup2` or `dup3` with safe Rust, which means it's not possible to observe the difference in behavior in that case, so remove the `dup3.rs` test. [`FilelikeView`]: https://docs.rs/io-lifetimes/latest/io_lifetimes/views/struct.FilelikeView.html
- Loading branch information
1 parent
9140010
commit 77c3daa
Showing
6 changed files
with
30 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters