Skip to content

Commit

Permalink
std::process (windows): Implement From<io::Stdout> etc. for imp::Stdio
Browse files Browse the repository at this point in the history
This involves a new variant `imp;::Stdio::InheritSpecific`.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
  • Loading branch information
ijackson committed Aug 7, 2023
1 parent deda7d3 commit 1bab95b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions library/std/src/sys/windows/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ pub struct Command {

pub enum Stdio {
Inherit,
InheritSpecific { from_stdio_id: c::DWORD },
Null,
MakePipe,
Pipe(AnonPipe),
Expand Down Expand Up @@ -533,6 +534,7 @@ impl Stdio {
};
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;
Expand Down Expand Up @@ -580,6 +582,18 @@ impl From<File> for 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
////////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 1bab95b

Please sign in to comment.