From 1ec9415e83878b8684919ef408a0b78e15dd0f3d Mon Sep 17 00:00:00 2001 From: mattsu Date: Fri, 16 Jan 2026 09:12:36 +0900 Subject: [PATCH 1/3] feat(install): add SIGPIPE handling for Unix pipeline compatibility Restore SIGPIPE signal to default disposition on Unix systems if not explicitly ignored by parent, ensuring proper pipeline behavior and GNU install compatibility. The Rust runtime ignores SIGPIPE by default, but this change respects the parent's signal settings for better script integration. --- src/uu/install/src/install.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/uu/install/src/install.rs b/src/uu/install/src/install.rs index d3e0b3e89a4..6d0e0950b2d 100644 --- a/src/uu/install/src/install.rs +++ b/src/uu/install/src/install.rs @@ -32,6 +32,8 @@ use uucore::selinux::{ SeLinuxError, contexts_differ, get_selinux_security_context, is_selinux_enabled, selinux_error_description, set_selinux_security_context, }; +#[cfg(unix)] +use uucore::signals; use uucore::translate; use uucore::{format_usage, show, show_error, show_if_err}; @@ -172,8 +174,22 @@ static ARG_FILES: &str = "files"; /// /// Returns a program return code. /// +// Initialize SIGPIPE state capture at process startup (Unix only) +#[cfg(unix)] +uucore::init_sigpipe_capture!(); + #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { + // Restore SIGPIPE to default if it wasn't explicitly ignored by parent. + // The Rust runtime ignores SIGPIPE, but we need to respect the parent's + // signal disposition for proper pipeline behavior (GNU compatibility). + #[cfg(unix)] + if !signals::sigpipe_was_ignored() { + // Ignore the return value: if setting signal handler fails, we continue anyway. + // The worst case is we don't get proper SIGPIPE behavior, but install will still work. + let _ = signals::enable_pipe_errors(); + } + let matches = uucore::clap_localization::handle_clap_result(uu_app(), args)?; let paths: Vec = matches From c4ad5293ee99874f5de5d597a1a3a4e81a993918 Mon Sep 17 00:00:00 2001 From: mattsu Date: Fri, 16 Jan 2026 09:17:22 +0900 Subject: [PATCH 2/3] refactor(install): reposition doc comment above uumain function Move the documentation comment for the main install utility function from above the SIGPIPE initialization to directly above the uumain function for better code organization and clarity. --- src/uu/install/src/install.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/uu/install/src/install.rs b/src/uu/install/src/install.rs index 6d0e0950b2d..bfc58f738f5 100644 --- a/src/uu/install/src/install.rs +++ b/src/uu/install/src/install.rs @@ -170,14 +170,14 @@ static OPT_UNPRIVILEGED: &str = "unprivileged"; static ARG_FILES: &str = "files"; -/// Main install utility function, called from main.rs. -/// -/// Returns a program return code. -/// // Initialize SIGPIPE state capture at process startup (Unix only) #[cfg(unix)] uucore::init_sigpipe_capture!(); +/// Main install utility function, called from main.rs. +/// +/// Returns a program return code. +/// #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { // Restore SIGPIPE to default if it wasn't explicitly ignored by parent. From 9c6b03793c2ff61a3b8dcd117ad51992c2896b33 Mon Sep 17 00:00:00 2001 From: mattsu Date: Fri, 16 Jan 2026 09:20:50 +0900 Subject: [PATCH 3/3] feat(install): enable signals feature in uucore dependency Add "signals" to the uucore features list to support signal handling in the install utility, improving responsiveness to interrupts and system signals. --- src/uu/install/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/uu/install/Cargo.toml b/src/uu/install/Cargo.toml index 9eb7679a404..d2308924e74 100644 --- a/src/uu/install/Cargo.toml +++ b/src/uu/install/Cargo.toml @@ -31,6 +31,7 @@ uucore = { workspace = true, default-features = true, features = [ "perms", "entries", "process", + "signals", ] } fluent = { workspace = true }