std: Improve pipe() functionality
* os::pipe() now returns IoResult<os::Pipe> * os::pipe() is now unsafe because it does not arrange for deallocation of file descriptors * os::Pipe fields are renamed from input to reader and out to write. * PipeStream::pair() has been added. This is a safe method to get a pair of pipes. * Dealing with pipes in native process bindings have been improved to be more robust in the face of failure and intermittent errors. This converts a few fail!() situations to Err situations. Closes #9458 cc #13538 Closes #14724 [breaking-change]
This commit is contained in:
parent
0b32d42a5d
commit
04eced750e
7 changed files with 211 additions and 118 deletions
|
|
@ -16,12 +16,12 @@ use std::io::PipeStream;
|
|||
use std::io::Command;
|
||||
|
||||
fn test() {
|
||||
let os::Pipe { input, out } = os::pipe();
|
||||
let input = PipeStream::open(input);
|
||||
let mut out = PipeStream::open(out);
|
||||
drop(input);
|
||||
let os::Pipe { reader, writer } = unsafe { os::pipe().unwrap() };
|
||||
let reader = PipeStream::open(reader);
|
||||
let mut writer = PipeStream::open(writer);
|
||||
drop(reader);
|
||||
|
||||
let _ = out.write([1]);
|
||||
let _ = writer.write([1]);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue