diff --git a/src/uu/cat/Cargo.toml b/src/uu/cat/Cargo.toml index 632a0d97b87..7dbd1ecbf32 100644 --- a/src/uu/cat/Cargo.toml +++ b/src/uu/cat/Cargo.toml @@ -21,7 +21,7 @@ path = "src/cat.rs" clap = { workspace = true } memchr = { workspace = true } thiserror = { workspace = true } -uucore = { workspace = true, features = ["fast-inc", "fs", "pipes"] } +uucore = { workspace = true, features = ["fast-inc", "fs", "pipes", "signals"] } fluent = { workspace = true } [target.'cfg(unix)'.dependencies] diff --git a/src/uu/cat/src/cat.rs b/src/uu/cat/src/cat.rs index 3497429d2de..4e5f07205e7 100644 --- a/src/uu/cat/src/cat.rs +++ b/src/uu/cat/src/cat.rs @@ -20,8 +20,6 @@ use std::os::unix::fs::FileTypeExt; use thiserror::Error; use uucore::display::Quotable; use uucore::error::UResult; -#[cfg(not(target_os = "windows"))] -use uucore::libc; use uucore::translate; use uucore::{fast_inc::fast_inc_one, format_usage}; @@ -225,9 +223,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { // (see https://github.com/rust-lang/rust/issues/62569), so we restore it's // default action here. #[cfg(not(target_os = "windows"))] - unsafe { - libc::signal(libc::SIGPIPE, libc::SIG_DFL); - } + let _ = uucore::signals::enable_pipe_errors(); let matches = uucore::clap_localization::handle_clap_result(uu_app(), args)?; diff --git a/src/uu/env/src/env.rs b/src/uu/env/src/env.rs index d715d3e9ec1..40f32b7656a 100644 --- a/src/uu/env/src/env.rs +++ b/src/uu/env/src/env.rs @@ -1098,9 +1098,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { // Rust ignores SIGPIPE (see https://github.com/rust-lang/rust/issues/62569). // We restore its default action here. #[cfg(unix)] - unsafe { - libc::signal(libc::SIGPIPE, libc::SIG_DFL); - } + let _ = uucore::signals::enable_pipe_errors(); EnvAppData::default().run_env(args) } diff --git a/src/uu/tail/Cargo.toml b/src/uu/tail/Cargo.toml index 7d7b57a74a3..732278732f0 100644 --- a/src/uu/tail/Cargo.toml +++ b/src/uu/tail/Cargo.toml @@ -23,7 +23,7 @@ clap = { workspace = true } libc = { workspace = true } memchr = { workspace = true } notify = { workspace = true } -uucore = { workspace = true, features = ["fs", "parser-size"] } +uucore = { workspace = true, features = ["fs", "parser-size", "signals"] } same-file = { workspace = true } fluent = { workspace = true } diff --git a/src/uu/tail/src/tail.rs b/src/uu/tail/src/tail.rs index cd10203b3f7..56bf155049c 100644 --- a/src/uu/tail/src/tail.rs +++ b/src/uu/tail/src/tail.rs @@ -45,9 +45,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { // (see https://github.com/rust-lang/rust/issues/62569), so we restore it's // default action here. #[cfg(not(target_os = "windows"))] - unsafe { - libc::signal(libc::SIGPIPE, libc::SIG_DFL); - } + let _ = uucore::signals::enable_pipe_errors(); let settings = parse_args(args)?; diff --git a/src/uu/tr/Cargo.toml b/src/uu/tr/Cargo.toml index c20e102d11e..0ab2ca9dd60 100644 --- a/src/uu/tr/Cargo.toml +++ b/src/uu/tr/Cargo.toml @@ -20,7 +20,7 @@ path = "src/tr.rs" [dependencies] nom = { workspace = true } clap = { workspace = true } -uucore = { workspace = true, features = ["fs"] } +uucore = { workspace = true, features = ["fs", "signals"] } fluent = { workspace = true } bytecount = { workspace = true, features = ["runtime-dispatch-simd"] } diff --git a/src/uu/tr/src/tr.rs b/src/uu/tr/src/tr.rs index d9349baa5bb..2b20d29ce86 100644 --- a/src/uu/tr/src/tr.rs +++ b/src/uu/tr/src/tr.rs @@ -18,8 +18,6 @@ use std::io::{stdin, stdout}; use uucore::display::Quotable; use uucore::error::{UResult, USimpleError, UUsageError}; use uucore::fs::is_stdin_directory; -#[cfg(not(target_os = "windows"))] -use uucore::libc; use uucore::translate; use uucore::{format_usage, os_str_as_bytes, show}; @@ -38,9 +36,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { // (see https://github.com/rust-lang/rust/issues/62569), so we restore it's // default action here. #[cfg(not(target_os = "windows"))] - unsafe { - libc::signal(libc::SIGPIPE, libc::SIG_DFL); - } + let _ = uucore::signals::enable_pipe_errors(); let matches = uucore::clap_localization::handle_clap_result(uu_app(), args)?;