]> git.proxmox.com Git - rustc.git/blob - src/test/ui/process/process-sigpipe.rs
New upstream version 1.65.0+dfsg1
[rustc.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 // ignore-fuchsia no 'sh'
18
19 use std::process;
20 use std::thread;
21
22 #[cfg(unix)]
23 fn main() {
24 // Just in case `yes` doesn't check for EPIPE...
25 thread::spawn(|| {
26 thread::sleep_ms(5000);
27 process::exit(1);
28 });
29 let output = process::Command::new("sh").arg("-c").arg("yes | head").output().unwrap();
30 assert!(output.status.success());
31 assert!(output.stderr.len() == 0);
32 }
33
34 #[cfg(not(unix))]
35 fn main() {
36 // Not worried about signal masks on other platforms
37 }