]> git.lizzy.rs Git - rust.git/blob - src/test/ui/sigpipe-should-be-ignored.rs
Auto merge of #67000 - spastorino:remove-promoted-from-place, r=oli-obk
[rust.git] / src / test / ui / sigpipe-should-be-ignored.rs
1 // run-pass
2
3 #![allow(unused_must_use)]
4 // Be sure that when a SIGPIPE would have been received that the entire process
5 // doesn't die in a ball of fire, but rather it's gracefully handled.
6
7 // ignore-cloudabi no processes
8 // ignore-emscripten no processes
9 // ignore-sgx no processes
10
11 use std::env;
12 use std::io::prelude::*;
13 use std::io;
14 use std::process::{Command, Stdio};
15
16 fn test() {
17     let _ = io::stdin().read_line(&mut String::new());
18     io::stdout().write(&[1]);
19     assert!(io::stdout().flush().is_err());
20 }
21
22 fn main() {
23     let args: Vec<String> = env::args().collect();
24     if args.len() > 1 && args[1] == "test" {
25         return test();
26     }
27
28     let mut p = Command::new(&args[0])
29                         .stdout(Stdio::piped())
30                         .stdin(Stdio::piped())
31                         .arg("test").spawn().unwrap();
32     drop(p.stdout.take());
33     assert!(p.wait().unwrap().success());
34 }