2018-08-30 07:18:55 -05:00
|
|
|
// run-pass
|
2018-09-27 03:14:57 -05:00
|
|
|
#![allow(unused_imports)]
|
2018-08-31 08:02:01 -05:00
|
|
|
#![allow(deprecated)]
|
|
|
|
|
2015-05-23 21:25:49 -05: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 02:34:43 -05:00
|
|
|
// filter behavior.
|
|
|
|
// This test checks that `while echo y ; do : ; done | head` terminates
|
2015-05-23 21:25:49 -05:00
|
|
|
// (instead of running forever), and that it does not print an error
|
|
|
|
// message about a broken pipe.
|
|
|
|
|
2016-02-11 05:34:41 -06:00
|
|
|
// ignore-emscripten no threads support
|
2019-07-28 11:15:43 -05:00
|
|
|
// ignore-vxworks no 'sh'
|
2022-09-12 17:38:49 -05:00
|
|
|
// ignore-fuchsia no 'sh'
|
2016-02-11 05:34:41 -06:00
|
|
|
|
2015-05-23 21:25:49 -05: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 02:34:43 -05:00
|
|
|
let output = process::Command::new("sh")
|
|
|
|
.arg("-c")
|
|
|
|
.arg("while echo y ; do : ; done | head")
|
|
|
|
.output()
|
|
|
|
.unwrap();
|
2015-05-23 21:25:49 -05:00
|
|
|
assert!(output.status.success());
|
|
|
|
assert!(output.stderr.len() == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(not(unix))]
|
|
|
|
fn main() {
|
|
|
|
// Not worried about signal masks on other platforms
|
|
|
|
}
|