std: reorganize pipe implementations by joboet · Pull Request #146794 · rust-lang/rust (original) (raw)
Currently, there are two distinct types called AnonPipe in std:
- The one used to implement
io::pipe(insys::anonymous_pipe) - The one used to implement
Stdin/Stdout/Stderr(insys::pal::pipe)
On Windows, these actually have different semantics, as one of the handles returned by the sys::pal::pipe version is opened for asynchronous operation in order to support read2, whereas the sys::anonymous_pipe version does not do so. Thus the naming is extremely confusing.
To fix this, this PR renames the sys::anonymous_pipe version of AnonPipe to simply Pipe, whereas the sys::pal::pipe version is now called ChildPipe. Additionally,
sys::anonymous_pipeis now also just calledsys::pipe.- On Windows,
sys::pal::pipehas been moved tosys::processand is now calledsys::process::child_pipe. - On non-Windows platforms, pipe creation is now exclusively handled by
sys::pipeandChildPipeis defined as a type alias toPipewithinsys::process.
And lastly, the read2 function (originally in sys::pal::pipe) is now called read_output and defined by sys::process, as (at least on Windows) it is only usable with ChildPipe.
Includes #146639 for convenience.