Skip to content

Commit

Permalink
agent: re-enable the standard SIGPIPE behavior
Browse files Browse the repository at this point in the history
The Rust standard library had suppressed the default SIGPIPE
behavior, see rust-lang/rust#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.

Fixes: kata-containers#1887

Signed-off-by: fupan.lfp <fupan.lfp@antgroup.com>
(cherry picked from commit 0ae364c)
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
  • Loading branch information
fupan.lfp authored and fidencio committed May 31, 2021
1 parent 8019f73 commit a05e137
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/agent/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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};

0 comments on commit a05e137

Please sign in to comment.