std::process (windows): Implement From<io::Stdout> etc. for imp::Stdio

This involves a new variant `imp;::Stdio::InheritSpecific`.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
This commit is contained in:
Ian Jackson 2021-11-08 18:38:04 +00:00
parent deda7d3301
commit 1bab95bf7f

View File

@ -170,6 +170,7 @@ pub struct Command {
pub enum Stdio {
Inherit,
InheritSpecific { from_stdio_id: c::DWORD },
Null,
MakePipe,
Pipe(AnonPipe),
@ -533,6 +534,7 @@ fn to_handle(&self, stdio_id: c::DWORD, pipe: &mut Option<AnonPipe>) -> io::Resu
};
match *self {
Stdio::Inherit => use_stdio_id(stdio_id),
Stdio::InheritSpecific { from_stdio_id } => use_stdio_id(from_stdio_id),
Stdio::MakePipe => {
let ours_readable = stdio_id != c::STD_INPUT_HANDLE;
@ -580,6 +582,18 @@ fn from(file: File) -> Stdio {
}
}
impl From<io::Stdout> for Stdio {
fn from(_: io::Stdout) -> Stdio {
Stdio::InheritSpecific { from_stdio_id: c::STD_OUTPUT_HANDLE }
}
}
impl From<io::Stderr> for Stdio {
fn from(_: io::Stderr) -> Stdio {
Stdio::InheritSpecific { from_stdio_id: c::STD_ERROR_HANDLE }
}
}
////////////////////////////////////////////////////////////////////////////////
// Processes
////////////////////////////////////////////////////////////////////////////////