]> git.lizzy.rs Git - rust.git/commit
Auto merge of #103459 - ChrisDenton:propagate-nulls, r=thomcc
authorbors <bors@rust-lang.org>
Wed, 7 Dec 2022 13:52:52 +0000 (13:52 +0000)
committerbors <bors@rust-lang.org>
Wed, 7 Dec 2022 13:52:52 +0000 (13:52 +0000)
commit01fbc5ae789fc0c7a2da71d3cd908451f175e4eb
treeb5b7cc6674469e94e328d494e162d34fb5b49ddd
parent91b8f34ac2272e3c94a97bebc033abe8e2f17101
parent93b774a2a47e813fd01481dab480d4be785c4427
Auto merge of #103459 - ChrisDenton:propagate-nulls, r=thomcc

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`