0
0
mirror of https://github.com/rust-lang/rust.git synced 2024-12-01 13:18:54 +01:00
rust/library/std/tests/pipe_subprocess.rs
Nicholas Nethercote 84ac80f192 Reformat use declarations.
The previous commit updated `rustfmt.toml` appropriately. This commit is
the outcome of running `x fmt --all` with the new formatting options.
2024-07-29 08:26:52 +10:00

42 lines
961 B
Rust

#![feature(anonymous_pipe)]
fn main() {
#[cfg(all(not(miri), any(unix, windows)))]
{
use std::io::Read;
use std::pipe::pipe;
use std::{env, process};
if env::var("I_AM_THE_CHILD").is_ok() {
child();
} else {
parent();
}
fn parent() {
let me = env::current_exe().unwrap();
let (rx, tx) = pipe().unwrap();
assert!(
process::Command::new(me)
.env("I_AM_THE_CHILD", "1")
.stdout(tx)
.status()
.unwrap()
.success()
);
let mut s = String::new();
(&rx).read_to_string(&mut s).unwrap();
drop(rx);
assert_eq!(s, "Heloo,\n");
println!("Test pipe_subprocess.rs success");
}
fn child() {
println!("Heloo,");
}
}
}