2018-08-30 12:18:55 +00:00
|
|
|
// run-pass
|
2018-09-27 08:14:57 +00:00
|
|
|
#![allow(unused_imports)]
|
2018-08-31 13:02:01 +00:00
|
|
|
#![allow(deprecated)]
|
|
|
|
|
2015-05-24 02:25:49 +00:00
|
|
|
// ignore-android since the dynamic linker sets a SIGPIPE handler (to do
|
|
|
|
// a crash report) so inheritance is moot on the entire platform
|
|
|
|
|
|
|
|
// libstd ignores SIGPIPE, and other libraries may set signal masks.
|
|
|
|
// Make sure that these behaviors don't get inherited to children
|
|
|
|
// spawned via std::process, since they're needed for traditional UNIX
|
2023-03-20 07:34:43 +00:00
|
|
|
// filter behavior.
|
|
|
|
// This test checks that `while echo y ; do : ; done | head` terminates
|
2015-05-24 02:25:49 +00:00
|
|
|
// (instead of running forever), and that it does not print an error
|
|
|
|
// message about a broken pipe.
|
|
|
|
|
2016-02-11 11:34:41 +00:00
|
|
|
// ignore-emscripten no threads support
|
2019-07-28 16:15:43 +00:00
|
|
|
// ignore-vxworks no 'sh'
|
2022-09-12 22:38:49 +00:00
|
|
|
// ignore-fuchsia no 'sh'
|
2016-02-11 11:34:41 +00:00
|
|
|
|
2015-05-24 02:25:49 +00:00
|
|
|
use std::process;
|
|
|
|
use std::thread;
|
|
|
|
|
|
|
|
#[cfg(unix)]
|
|
|
|
fn main() {
|
|
|
|
// Just in case `yes` doesn't check for EPIPE...
|
|
|
|
thread::spawn(|| {
|
|
|
|
thread::sleep_ms(5000);
|
|
|
|
process::exit(1);
|
|
|
|
});
|
2023-03-20 07:34:43 +00:00
|
|
|
let output = process::Command::new("sh")
|
|
|
|
.arg("-c")
|
|
|
|
.arg("while echo y ; do : ; done | head")
|
|
|
|
.output()
|
|
|
|
.unwrap();
|
2015-05-24 02:25:49 +00:00
|
|
|
assert!(output.status.success());
|
|
|
|
assert!(output.stderr.len() == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(not(unix))]
|
|
|
|
fn main() {
|
|
|
|
// Not worried about signal masks on other platforms
|
|
|
|
}
|