]> git.proxmox.com Git - rustc.git/blob - src/test/ui/process/issue-14456.rs
New upstream version 1.67.1+dfsg1
[rustc.git] / src / test / ui / process / issue-14456.rs
1 // run-pass
2 #![allow(unused_mut)]
3 // ignore-emscripten no processes
4 // ignore-sgx no processes
5
6 use std::env;
7 use std::io::prelude::*;
8 use std::io;
9 use std::process::{Command, Stdio};
10
11 fn main() {
12 let args: Vec<String> = env::args().collect();
13 if args.len() > 1 && args[1] == "child" {
14 return child()
15 }
16
17 test();
18 }
19
20 fn child() {
21 writeln!(&mut io::stdout(), "foo").unwrap();
22 writeln!(&mut io::stderr(), "bar").unwrap();
23 let mut stdin = io::stdin();
24 let mut s = String::new();
25 stdin.lock().read_line(&mut s).unwrap();
26 assert_eq!(s.len(), 0);
27 }
28
29 fn test() {
30 let args: Vec<String> = env::args().collect();
31 let mut p = Command::new(&args[0]).arg("child")
32 .stdin(Stdio::piped())
33 .stdout(Stdio::piped())
34 .stderr(Stdio::piped())
35 .spawn().unwrap();
36 assert!(p.wait().unwrap().success());
37 }