Skip to content

Commit

Permalink
Auto merge of #103459 - ChrisDenton:propagate-nulls, r=thomcc
Browse files Browse the repository at this point in the history
Pass on null handle values to child process

Fixes #101645

In Windows, stdio handles are (semantically speaking) `Option<Handle>` where `Handle` is a non-zero value. When spawning a process with `Stdio::Inherit`, Rust currently turns zero values into `-1` values. This has the unfortunate effect of breaking console subprocesses (which typically need stdio) that are spawned from gui applications (that lack stdio by default) because the console process won't be assigned handles from the newly created console (as they usually would in that situation). Worse, `-1` is actually [a valid handle](https://doc.rust-lang.org/std/os/windows/io/struct.OwnedHandle.html) which means "the current process". So if a console process, for example, waits on stdin and it has a `-1` value then the process will end up waiting on itself.

This PR fixes it by propagating the nulls instead of converting them to `-1`.

While I think the current behaviour is a mistake, changing it (however justified) is an API change so I think this PR should at least have some input from t-libs-api. So choosing at random...

r? `@joshtriplett`
  • Loading branch information
bors committed Dec 7, 2022
2 parents a3cc186 + bf380d7 commit 09d2a93
Showing 0 changed files with 0 additions and 0 deletions.

0 comments on commit 09d2a93

Please sign in to comment.