Windows: Propagate null handle values when inheriting #137
Labels
ACP-accepted
API Change Proposal is accepted (seconded with no objections)
api-change-proposal
A proposal to add or alter unstable APIs in the standard libraries
T-libs-api
Proposal
Problem statement
In Windows, stdio handles are (semantically speaking)
Option<Handle>
whereHandle
is a non-zero value andNone
is zero. When spawning a process withStdio::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 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 instead of input.Motivation, use-cases
Process
a.exe
:Process
b.exe
:Solution sketches
These problems can be fixed by properly propagating the zero values instead of converting them to
-1
. This does mean that there is behaviour change here but I feel they're justified.Links and related work
What happens now?
This issue is part of the libs-api team API change proposal process. Once this issue is filed the libs-api team will review open proposals in its weekly meeting. You should receive feedback within a week or two.
The text was updated successfully, but these errors were encountered: