rust/library/std/src/sys/windows
bors 01fbc5ae78 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`
2022-12-07 13:52:52 +00:00
..
alloc Rework std::sys::windows::alloc 2021-03-26 12:38:26 +01:00
args Update Windows arg parsing tests 2021-08-08 22:11:29 +01:00
c Windows error codes: Add two missing ones 2021-06-18 18:51:53 +01:00
handle Tests for unsound Windows file methods 2022-07-06 17:40:21 +01:00
locks std: remove lock wrappers in sys_common 2022-11-06 15:32:59 +01:00
os Replace AlignedAs with a more specific Align8 type 2022-08-30 01:15:59 -07:00
path Restore old behaviour on broken UNC paths 2022-09-03 07:56:38 +01:00
process Expose process main_thread_handle on Windows 2022-05-10 02:41:19 -03:00
thread_local_key std: optimize TLS on Windows 2022-10-08 20:19:21 +02:00
alloc.rs Explicitly link kernel32.lib from alloc 2022-09-10 11:57:36 +01:00
args.rs Extract WStrUnits to sys_common::wstr 2022-11-28 21:17:08 +05:30
c.rs Rollup merge of #103995 - SUPERCILEX:typos, r=Dylan-DPC 2022-11-05 11:31:30 +05:30
cmath.rs Correct typo 2022-08-31 18:25:00 +08:00
compat.rs Reinstate preloading of some dll imports 2022-08-28 02:52:06 +01:00
env.rs
fs.rs Handle the case that even the filename array is unaligned. 2022-11-18 00:05:44 -08:00
handle.rs Address reviewer comments 2022-08-18 10:34:40 +01:00
io.rs Reduce false positives in msys2 detection 2022-10-21 18:06:12 +01:00
memchr.rs
mod.rs Use stdio in UWP apps 2022-10-27 17:21:30 +01:00
net.rs Represent SocketAddrV4 and SocketAddrV6 as Rust native encoding 2022-06-23 21:01:58 +02:00
os_str.rs Optimize Wtf8Buf::into_string for the case where it contains UTF-8. 2022-06-23 13:10:47 -07:00
os.rs Replace most uses of pointer::offset with add and sub 2022-08-21 02:21:41 +04:00
path.rs Restore old behaviour on broken UNC paths 2022-09-03 07:56:38 +01:00
pipe.rs Small round of typo fixes 2022-11-04 20:06:18 -07:00
process.rs Don't set STARTF_USESTDHANDLES if none are set 2022-12-06 17:26:21 +00:00
rand.rs Remove RtlGenRandom (take two) 2022-09-20 18:39:31 +01:00
stack_overflow_uwp.rs Move all cleanup to sys::cleanup 2021-04-22 10:44:44 +02:00
stack_overflow.rs Apply clippy suggestions 2021-10-09 18:56:01 +02:00
stdio.rs Avoid MaybeUninit::uninit_array() 2022-08-30 06:10:55 -07:00
thread_local_dtor.rs Never inline Windows dtor access 2022-08-01 03:53:16 +01:00
thread_local_key.rs std: optimize TLS on Windows 2022-10-08 20:19:21 +02:00
thread_parker.rs Windows: Load synch functions together 2022-08-18 07:39:14 +01:00
thread.rs Use Rust 2021 prelude in std itself. 2022-05-09 11:12:32 +02:00
time.rs Support setting file accessed/modified timestamps 2022-07-15 02:54:06 -07:00