-
Notifications
You must be signed in to change notification settings - Fork 681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dup2 and close potentially should be unsafe #1421
Comments
It's a tough call. On the one hand, Nix usually defers to rust-lang's reasoning on safety. If rust-lang says that |
That is absolutely fair. I already mentioned |
I'm working on a draft of a proposal to add new official wording about In particular, this proposal would mean that all functions with a |
I'm going to close this issue. But @sunfishcode please open a new one if that RFC ever gets fully implemented. Nix should definitely follow suit. |
See the discussion in rust-lang/rust#72175, in particular this comment: dup2 and close (and potentially more operations) can be used to destroy file descriptors that might be owned by other libraries, which in turn can lead to internal invariants of those libraries being violated. For this reason, the standard library makes
from_raw_fd
an unsafe operation. nix should, I think, follow suit and not expose safe operations that break the idea that a file descriptor can be exclusively owned.The text was updated successfully, but these errors were encountered: