]> git.proxmox.com Git - rustc.git/blame - src/test/ui/process/sigpipe-should-be-ignored.rs
New upstream version 1.67.1+dfsg1
[rustc.git] / src / test / ui / process / sigpipe-should-be-ignored.rs
CommitLineData
416331ca
XL
1// run-pass
2
0bf4aa26 3#![allow(unused_must_use)]
1a4d82fc
JJ
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
abe05a73 7// ignore-emscripten no processes
48663c56 8// ignore-sgx no processes
c34b1796 9
85aaf69f 10use std::env;
c34b1796
AL
11use std::io::prelude::*;
12use std::io;
13use std::process::{Command, Stdio};
1a4d82fc
JJ
14
15fn test() {
c34b1796
AL
16 let _ = io::stdin().read_line(&mut String::new());
17 io::stdout().write(&[1]);
18 assert!(io::stdout().flush().is_err());
1a4d82fc
JJ
19}
20
21fn main() {
85aaf69f
SL
22 let args: Vec<String> = env::args().collect();
23 if args.len() > 1 && args[1] == "test" {
1a4d82fc
JJ
24 return test();
25 }
26
85aaf69f 27 let mut p = Command::new(&args[0])
c34b1796
AL
28 .stdout(Stdio::piped())
29 .stdin(Stdio::piped())
1a4d82fc 30 .arg("test").spawn().unwrap();
c34b1796 31 drop(p.stdout.take());
1a4d82fc
JJ
32 assert!(p.wait().unwrap().success());
33}