When running a Command, it is often desirable to plumb stdout to the same place as stderr, as if 2>&1 in a shell rune.
Unfortunately, there is no way to do this with Command right now without writing unsafe, non-portable code.
Really we want to fix this so that you can pass to Command anything that implements AsRawFd, so probably the right thing would be std::Process::Stdio::reuse<F:AsRawFd>(fd: &f). The implementation is not entirely trivial - we need an fd-permuting algorithm that avoids making unnecessary calls to dup2.
On Windows that would be std::Process::Stdio::reuse<F:AsRawHandle>(fd: &f) I guess.
It's a shame that we have totally separate names for *RawFd and *RawHandle rather than a portable-opaque but nonportably-transparent OsOpenFileReference type and AsOsOpenFileReference, IntoOsOpenFileReference, FromOsOpenFileReference but that seems like rather a major change.
When running a
Command, it is often desirable to plumb stdout to the same place as stderr, as if2>&1in a shell rune.Unfortunately, there is no way to do this with
Commandright now without writingunsafe, non-portable code.Really we want to fix this so that you can pass to
Commandanything that implementsAsRawFd, so probably the right thing would bestd::Process::Stdio::reuse<F:AsRawFd>(fd: &f). The implementation is not entirely trivial - we need an fd-permuting algorithm that avoids making unnecessary calls todup2.On Windows that would be
std::Process::Stdio::reuse<F:AsRawHandle>(fd: &f)I guess.It's a shame that we have totally separate names for
*RawFdand*RawHandlerather than a portable-opaque but nonportably-transparentOsOpenFileReferencetype andAsOsOpenFileReference,IntoOsOpenFileReference,FromOsOpenFileReferencebut that seems like rather a major change.