Skip to content

Commit 0d3f67f

Browse files
committed
feat: add conditional signal handler for Redox OS compatibility
Make the ctrlc dependency and signal handler optional for Redox OS, which lacks signal support. Added cfg attributes to skip signal handling on Redox, preventing compilation errors. Also added clippy allow attributes for FreeBSD in fs.rs.
1 parent a8be8d3 commit 0d3f67f

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/uu/sort/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ bigdecimal = { workspace = true }
2424
binary-heap-plus = { workspace = true }
2525
clap = { workspace = true }
2626
compare = { workspace = true }
27-
ctrlc = { workspace = true }
2827
fnv = { workspace = true }
2928
itertools = { workspace = true }
3029
memchr = { workspace = true }
@@ -37,6 +36,9 @@ unicode-width = { workspace = true }
3736
uucore = { workspace = true, features = ["fs", "parser-size", "version-cmp"] }
3837
fluent = { workspace = true }
3938

39+
[target.'cfg(not(target_os = "redox"))'.dependencies]
40+
ctrlc = { workspace = true }
41+
4042
[target.'cfg(unix)'.dependencies]
4143
nix = { workspace = true, features = ["resource"] }
4244

src/uu/sort/src/tmp_dir.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ fn should_install_signal_handler() -> bool {
5555
open_fds.saturating_add(CTRL_C_FDS + RESERVED_FOR_MERGE) <= limit
5656
}
5757

58+
#[cfg(not(target_os = "redox"))]
5859
fn ensure_signal_handler_installed(state: Arc<Mutex<HandlerRegistration>>) -> UResult<()> {
5960
// This shared state must originate from `handler_state()` so the handler always sees
6061
// the current lock/path pair and can clean up the active temp directory on SIGINT.
@@ -104,6 +105,11 @@ fn ensure_signal_handler_installed(state: Arc<Mutex<HandlerRegistration>>) -> UR
104105
Ok(())
105106
}
106107

108+
#[cfg(target_os = "redox")]
109+
fn ensure_signal_handler_installed(_state: Arc<Mutex<HandlerRegistration>>) -> UResult<()> {
110+
Ok(())
111+
}
112+
107113
impl TmpDirWrapper {
108114
pub fn new(path: PathBuf) -> Self {
109115
Self {

src/uucore/src/lib/features/fs.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ impl FileInformation {
149149
not(target_pointer_width = "64")
150150
)
151151
))]
152+
#[cfg_attr(target_os = "freebsd", allow(clippy::useless_conversion))]
152153
return self.0.st_nlink.into();
153154
#[cfg(target_os = "aix")]
154155
return self.0.st_nlink.try_into().unwrap();
@@ -168,6 +169,7 @@ impl FileInformation {
168169
target_os = "netbsd",
169170
not(target_pointer_width = "64")
170171
))]
172+
#[cfg_attr(target_os = "freebsd", allow(clippy::useless_conversion))]
171173
return self.0.st_ino.into();
172174
}
173175
}

0 commit comments

Comments
 (0)