std: reorganize pipe implementations by joboet · Pull Request #146794 · rust-lang/rust (original) (raw)

Currently, there are two distinct types called AnonPipe in std:

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,

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.