Skip to content

Commit

Permalink
Remove redundant code for handling NULL handles on Windows.
Browse files Browse the repository at this point in the history
Before calling `CreateProcessW`, stdio handles are passed through
`stdio::get_handle`, which already converts NULL to
`INVALID_HANDLE_VALUE`, so we don't need extra checks for NULL after
that point.
  • Loading branch information
sunfishcode committed Mar 4, 2022
1 parent 7dd3246 commit 7ddf41c
Showing 1 changed file with 0 additions and 13 deletions.
13 changes: 0 additions & 13 deletions library/std/src/sys/windows/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,19 +309,6 @@ impl Command {
si.hStdOutput = stdout.as_raw_handle();
si.hStdError = stderr.as_raw_handle();

// `CreateProcessW` fails with `ERROR_FILE_NOT_FOUND` if any of the
// stdio handles are null, so if we have null handles, set them to
// `INVALID_HANDLE_VALUE`.
if si.hStdInput.is_null() {
si.hStdInput = c::INVALID_HANDLE_VALUE;
}
if si.hStdOutput.is_null() {
si.hStdOutput = c::INVALID_HANDLE_VALUE;
}
if si.hStdError.is_null() {
si.hStdError = c::INVALID_HANDLE_VALUE;
}

let program = to_u16s(&program)?;
unsafe {
cvt(c::CreateProcessW(
Expand Down

0 comments on commit 7ddf41c

Please sign in to comment.