-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
T-libs-apiRelevant to the library API team, which will review and decide on the RFC.Relevant to the library API team, which will review and decide on the RFC.
Description
Writing this issue was triggered by the question How to properly pipe commands in Rust. Currently, the answer is:
.stdin(unsafe { Stdio::from_raw_fd(cmd.stdout.unwrap().as_raw_fd()) })
This is fairly verbose, but more importantly requires unsafe
code.
Similar (also unsafe
) code can be used to create Stdio
from other things like a file or a socket.
For those conversions that are safe⁽¹⁾, the standard library should provide a way to do them without using unsafe
. For example, Stdio
could implement From<ChildStdout>
, From<File>
, etc. Or maybe From<T> where T: IntoRawFd
/ T: IntoRawHandle
.
⁽¹⁾ Some combinations seem incorrect, e.g. taking the reading end of a pipe (ChildStdout
) and using it for writing (Command::stdout
), but can they cause undefined behavior?
danielrh and nsmaciej
Metadata
Metadata
Assignees
Labels
T-libs-apiRelevant to the library API team, which will review and decide on the RFC.Relevant to the library API team, which will review and decide on the RFC.