Skip to content

Commit ad7658e

Browse files
fupan.lfpfidencio
fupan.lfp
authored andcommitted
agent: re-enable the standard SIGPIPE behavior
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 <[email protected]> (cherry picked from commit 0ae364c) Signed-off-by: Fabiano Fidêncio <[email protected]>
1 parent 009a200 commit ad7658e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/agent/src/main.rs

+12
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
248248
}
249249

250250
if args.len() == 2 && args[1] == "init" {
251+
reset_sigpipe();
251252
rustjail::container::init_child();
252253
exit(0);
253254
}
@@ -358,5 +359,16 @@ fn sethostname(hostname: &OsStr) -> Result<()> {
358359
}
359360
}
360361

362+
// The Rust standard library had suppressed the default SIGPIPE behavior,
363+
// see https://github.com/rust-lang/rust/pull/13158.
364+
// Since the parent's signal handler would be inherited by it's child process,
365+
// thus we should re-enable the standard SIGPIPE behavior as a workaround to
366+
// fix the issue of https://github.com/kata-containers/kata-containers/issues/1887.
367+
fn reset_sigpipe() {
368+
unsafe {
369+
libc::signal(libc::SIGPIPE, libc::SIG_DFL);
370+
}
371+
}
372+
361373
use crate::config::AgentConfig;
362374
use std::os::unix::io::{FromRawFd, RawFd};

0 commit comments

Comments
 (0)