]> git.lizzy.rs Git - rust.git/blob - tests/ui/process/sigpipe-should-be-ignored.rs
Rollup merge of #106446 - bzEq:fix-unwind-lsda, r=Amanieu
[rust.git] / tests / ui / process / 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-emscripten no processes
8 // ignore-sgx no processes
9
10 use std::env;
11 use std::io::prelude::*;
12 use std::io;
13 use std::process::{Command, Stdio};
14
15 fn test() {
16     let _ = io::stdin().read_line(&mut String::new());
17     io::stdout().write(&[1]);
18     assert!(io::stdout().flush().is_err());
19 }
20
21 fn main() {
22     let args: Vec<String> = env::args().collect();
23     if args.len() > 1 && args[1] == "test" {
24         return test();
25     }
26
27     let mut p = Command::new(&args[0])
28                         .stdout(Stdio::piped())
29                         .stdin(Stdio::piped())
30                         .arg("test").spawn().unwrap();
31     drop(p.stdout.take());
32     assert!(p.wait().unwrap().success());
33 }