Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions fuzz/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion src/uu/sort/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,17 @@ uucore = { workspace = true, features = [
fluent = { workspace = true }
foldhash = { workspace = true }

[target.'cfg(all(unix, not(any(target_os = "redox", target_os = "fuchsia", target_os = "haiku", target_os = "solaris", target_os = "illumos"))))'.dependencies]
rustix = { workspace = true, features = ["process"] }

[target.'cfg(not(any(target_os = "redox", target_os = "wasi")))'.dependencies]
ctrlc = { workspace = true }

[target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies]
nix = { workspace = true }

[target.'cfg(unix)'.dependencies]
nix = { workspace = true, features = ["resource"] }
libc = { workspace = true }

[dev-dependencies]
divan = { workspace = true }
Expand Down
16 changes: 6 additions & 10 deletions src/uu/sort/src/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sort.html
// https://www.gnu.org/software/coreutils/manual/html_node/sort-invocation.html

// spell-checker:ignore (misc) HFKJFK Mbdfhn getrlimit RLIMIT_NOFILE rlim bigdecimal extendedbigdecimal hexdigit behaviour keydef GETFD localeconv foldhash
// spell-checker:ignore (misc) HFKJFK Mbdfhn getrlimit Nofile rlim bigdecimal extendedbigdecimal hexdigit behaviour keydef GETFD localeconv foldhash
// spell-checker:ignore (misc) uppercased qsort getmonth juin juil

mod buffer_hint;
Expand Down Expand Up @@ -1371,13 +1371,12 @@ fn make_sort_mode_arg(mode: &'static str, short: char, help: String) -> Arg {
))
))]
fn get_rlimit() -> UResult<usize> {
use nix::sys::resource::{RLIM_INFINITY, Resource, getrlimit};
use rustix::process::{Resource, getrlimit};

let rlim_cur = getrlimit(Resource::Nofile)
.current
.ok_or_else(|| UUsageError::new(2, translate!("sort-failed-fetch-rlimit")))?;

let (rlim_cur, _rlim_max) = getrlimit(Resource::RLIMIT_NOFILE)
.map_err(|_| UUsageError::new(2, translate!("sort-failed-fetch-rlimit")))?;
if rlim_cur == RLIM_INFINITY {
return Err(UUsageError::new(2, translate!("sort-failed-fetch-rlimit")));
}
usize::try_from(rlim_cur)
.map_err(|_| UUsageError::new(2, translate!("sort-failed-fetch-rlimit")))
}
Expand Down Expand Up @@ -1410,8 +1409,6 @@ pub(crate) fn fd_soft_limit() -> Option<usize> {

#[cfg(unix)]
pub(crate) fn current_open_fd_count() -> Option<usize> {
use nix::libc;

fn count_dir(path: &str) -> Option<usize> {
let entries = std::fs::read_dir(path).ok()?;
let mut count = 0usize;
Expand Down Expand Up @@ -1770,7 +1767,6 @@ fn locale_failed_to_set() -> bool {

#[cfg(unix)]
fn locale_failed_to_set() -> bool {
use nix::libc;
unsafe { libc::setlocale(libc::LC_COLLATE, c"".as_ptr()).is_null() }
}

Expand Down
Loading