]> git.lizzy.rs Git - rust.git/blob - src/test/ui/process/process-sigpipe.rs
Pin panic-in-drop=abort test to old pass manager
[rust.git] / src / test / ui / process / process-sigpipe.rs
1 // run-pass
2 #![allow(unused_imports)]
3 #![allow(deprecated)]
4
5 // ignore-android since the dynamic linker sets a SIGPIPE handler (to do
6 // a crash report) so inheritance is moot on the entire platform
7
8 // libstd ignores SIGPIPE, and other libraries may set signal masks.
9 // Make sure that these behaviors don't get inherited to children
10 // spawned via std::process, since they're needed for traditional UNIX
11 // filter behavior. This test checks that `yes | head` terminates
12 // (instead of running forever), and that it does not print an error
13 // message about a broken pipe.
14
15 // ignore-emscripten no threads support
16 // ignore-vxworks no 'sh'
17
18 use std::process;
19 use std::thread;
20
21 #[cfg(unix)]
22 fn main() {
23     // Just in case `yes` doesn't check for EPIPE...
24     thread::spawn(|| {
25         thread::sleep_ms(5000);
26         process::exit(1);
27     });
28     let output = process::Command::new("sh").arg("-c").arg("yes | head").output().unwrap();
29     assert!(output.status.success());
30     assert!(output.stderr.len() == 0);
31 }
32
33 #[cfg(not(unix))]
34 fn main() {
35     // Not worried about signal masks on other platforms
36 }