Skip to content

Commit 76a8cc9

Browse files
committed
refactor(sort): exclude unsupported Unix OSes from fd limit checks
Exclude redox, fuchsia, haiku, solaris, and illumos from Unix-specific file descriptor soft limit functionality in get_rlimit and fd_soft_limit, returning None on unsupported platforms to avoid compilation or runtime issues.
1 parent 0d3f67f commit 76a8cc9

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

src/uu/sort/src/sort.rs

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,16 @@ fn make_sort_mode_arg(mode: &'static str, short: char, help: String) -> Arg {
10841084
)
10851085
}
10861086

1087-
#[cfg(unix)]
1087+
#[cfg(all(
1088+
unix,
1089+
not(any(
1090+
target_os = "redox",
1091+
target_os = "fuchsia",
1092+
target_os = "haiku",
1093+
target_os = "solaris",
1094+
target_os = "illumos"
1095+
))
1096+
))]
10881097
fn get_rlimit() -> UResult<usize> {
10891098
use nix::sys::resource::{RLIM_INFINITY, Resource, getrlimit};
10901099

@@ -1097,12 +1106,28 @@ fn get_rlimit() -> UResult<usize> {
10971106
.map_err(|_| UUsageError::new(2, translate!("sort-failed-fetch-rlimit")))
10981107
}
10991108

1100-
#[cfg(unix)]
1109+
#[cfg(all(
1110+
unix,
1111+
not(any(
1112+
target_os = "redox",
1113+
target_os = "fuchsia",
1114+
target_os = "haiku",
1115+
target_os = "solaris",
1116+
target_os = "illumos"
1117+
))
1118+
))]
11011119
pub(crate) fn fd_soft_limit() -> Option<usize> {
11021120
get_rlimit().ok()
11031121
}
11041122

1105-
#[cfg(not(unix))]
1123+
#[cfg(any(
1124+
not(unix),
1125+
target_os = "redox",
1126+
target_os = "fuchsia",
1127+
target_os = "haiku",
1128+
target_os = "solaris",
1129+
target_os = "illumos"
1130+
))]
11061131
pub(crate) fn fd_soft_limit() -> Option<usize> {
11071132
None
11081133
}

0 commit comments

Comments
 (0)