Merge pull request #1939 from lifupan/fix_epipe

agent: re-enable the standard SIGPIPE behavior
This commit is contained in:
Peng Tao 2021-05-29 10:05:09 +08:00 committed by GitHub
commit fd6d32ee42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -248,6 +248,7 @@ fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
}
if args.len() == 2 && args[1] == "init" {
reset_sigpipe();
rustjail::container::init_child();
exit(0);
}
@ -358,5 +359,16 @@ fn sethostname(hostname: &OsStr) -> Result<()> {
}
}
// The Rust standard library had suppressed the default SIGPIPE behavior,
// see https://github.com/rust-lang/rust/pull/13158.
// Since the parent's signal handler would be inherited by it's child process,
// thus we should re-enable the standard SIGPIPE behavior as a workaround to
// fix the issue of https://github.com/kata-containers/kata-containers/issues/1887.
fn reset_sigpipe() {
unsafe {
libc::signal(libc::SIGPIPE, libc::SIG_DFL);
}
}
use crate::config::AgentConfig;
use std::os::unix::io::{FromRawFd, RawFd};