Skip to content

Commit dc309e6

Browse files
committed
refactor(sort): restrict nix::libc and fd_soft_limit to Linux
Update conditional compilation attributes from #[cfg(unix)] to #[cfg(target_os = "linux")] for the nix::libc import and fd_soft_limit function implementations, ensuring these features are only enabled on Linux systems to improve portability and avoid issues on other Unix-like platforms.
1 parent 1715d4f commit dc309e6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/uu/sort/src/sort.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use clap::{Arg, ArgAction, Command};
2525
use custom_str_cmp::custom_str_cmp;
2626
use ext_sort::ext_sort;
2727
use fnv::FnvHasher;
28-
#[cfg(unix)]
28+
#[cfg(target_os = "linux")]
2929
use nix::libc;
3030
use numeric_str_cmp::{NumInfo, NumInfoParseSettings, human_numeric_str_cmp, numeric_str_cmp};
3131
use rand::{Rng, rng};
@@ -1072,7 +1072,7 @@ fn make_sort_mode_arg(mode: &'static str, short: char, help: String) -> Arg {
10721072
)
10731073
}
10741074

1075-
#[cfg(unix)]
1075+
#[cfg(target_os = "linux")]
10761076
pub(crate) fn fd_soft_limit() -> Option<usize> {
10771077
let mut limit = libc::rlimit {
10781078
rlim_cur: 0,
@@ -1092,7 +1092,7 @@ pub(crate) fn fd_soft_limit() -> Option<usize> {
10921092
}
10931093
}
10941094

1095-
#[cfg(not(unix))]
1095+
#[cfg(not(target_os = "linux"))]
10961096
pub(crate) fn fd_soft_limit() -> Option<usize> {
10971097
None
10981098
}

0 commit comments

Comments
 (0)