Skip to content

Commit c78ccfa

Browse files
committed
use the enable_pipe_errors instead of libc::signal
1 parent 23b11ea commit c78ccfa

File tree

7 files changed

+7
-19
lines changed

7 files changed

+7
-19
lines changed

src/uu/cat/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ path = "src/cat.rs"
2121
clap = { workspace = true }
2222
memchr = { workspace = true }
2323
thiserror = { workspace = true }
24-
uucore = { workspace = true, features = ["fast-inc", "fs", "pipes"] }
24+
uucore = { workspace = true, features = ["fast-inc", "fs", "pipes", "signals"] }
2525
fluent = { workspace = true }
2626

2727
[target.'cfg(unix)'.dependencies]

src/uu/cat/src/cat.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ use std::os::unix::fs::FileTypeExt;
2020
use thiserror::Error;
2121
use uucore::display::Quotable;
2222
use uucore::error::UResult;
23-
#[cfg(not(target_os = "windows"))]
24-
use uucore::libc;
2523
use uucore::translate;
2624
use uucore::{fast_inc::fast_inc_one, format_usage};
2725

@@ -225,9 +223,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
225223
// (see https://github.com/rust-lang/rust/issues/62569), so we restore it's
226224
// default action here.
227225
#[cfg(not(target_os = "windows"))]
228-
unsafe {
229-
libc::signal(libc::SIGPIPE, libc::SIG_DFL);
230-
}
226+
let _ = uucore::signals::enable_pipe_errors();
231227

232228
let matches = uucore::clap_localization::handle_clap_result(uu_app(), args)?;
233229

src/uu/env/src/env.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,9 +1098,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
10981098
// Rust ignores SIGPIPE (see https://github.com/rust-lang/rust/issues/62569).
10991099
// We restore its default action here.
11001100
#[cfg(unix)]
1101-
unsafe {
1102-
libc::signal(libc::SIGPIPE, libc::SIG_DFL);
1103-
}
1101+
let _ = uucore::signals::enable_pipe_errors();
11041102
EnvAppData::default().run_env(args)
11051103
}
11061104

src/uu/tail/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ clap = { workspace = true }
2323
libc = { workspace = true }
2424
memchr = { workspace = true }
2525
notify = { workspace = true }
26-
uucore = { workspace = true, features = ["fs", "parser-size"] }
26+
uucore = { workspace = true, features = ["fs", "parser-size", "signals"] }
2727
same-file = { workspace = true }
2828
fluent = { workspace = true }
2929

src/uu/tail/src/tail.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
4545
// (see https://github.com/rust-lang/rust/issues/62569), so we restore it's
4646
// default action here.
4747
#[cfg(not(target_os = "windows"))]
48-
unsafe {
49-
libc::signal(libc::SIGPIPE, libc::SIG_DFL);
50-
}
48+
let _ = uucore::signals::enable_pipe_errors();
5149

5250
let settings = parse_args(args)?;
5351

src/uu/tr/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ path = "src/tr.rs"
2020
[dependencies]
2121
nom = { workspace = true }
2222
clap = { workspace = true }
23-
uucore = { workspace = true, features = ["fs"] }
23+
uucore = { workspace = true, features = ["fs", "signals"] }
2424
fluent = { workspace = true }
2525
bytecount = { workspace = true, features = ["runtime-dispatch-simd"] }
2626

src/uu/tr/src/tr.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ use std::io::{stdin, stdout};
1818
use uucore::display::Quotable;
1919
use uucore::error::{UResult, USimpleError, UUsageError};
2020
use uucore::fs::is_stdin_directory;
21-
#[cfg(not(target_os = "windows"))]
22-
use uucore::libc;
2321
use uucore::translate;
2422
use uucore::{format_usage, os_str_as_bytes, show};
2523

@@ -38,9 +36,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
3836
// (see https://github.com/rust-lang/rust/issues/62569), so we restore it's
3937
// default action here.
4038
#[cfg(not(target_os = "windows"))]
41-
unsafe {
42-
libc::signal(libc::SIGPIPE, libc::SIG_DFL);
43-
}
39+
let _ = uucore::signals::enable_pipe_errors();
4440

4541
let matches = uucore::clap_localization::handle_clap_result(uu_app(), args)?;
4642

0 commit comments

Comments
 (0)