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
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,11 @@ runcon = { optional = true, version = "0.13.0", package = "uu_runcon", path = "s
# Not needed for now. Keep as examples:
#pin_cc = { version="1.0.61, < 1.0.62", package="cc" } ## cc v1.0.62 has compiler errors for MinRustV v1.32.0, requires 1.34 (for `std::str::split_ascii_whitespace()`)

[target.'cfg(all(unix, not(target_os = "fuchsia")))'.dev-dependencies]
rlimit = { workspace = true }

[target.'cfg(unix)'.dev-dependencies]
nix = { workspace = true, features = ["fs", "signal"] }
rlimit = { workspace = true }
rustix = { workspace = true, features = ["net", "process"] }

[build-dependencies]
Expand Down
4 changes: 3 additions & 1 deletion src/uu/sort/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ uucore = { workspace = true, features = [
[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 = ["fs", "system", "process"] }

[target.'cfg(all(unix, not(target_os = "fuchsia")))'.dependencies]
rlimit = { workspace = true }

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

[target.'cfg(unix)'.dependencies]
libc = { workspace = true }
rustix = { workspace = true, features = ["fs"] }
rlimit = { workspace = true }

[dev-dependencies]
divan = { workspace = true }
Expand Down
6 changes: 3 additions & 3 deletions src/uu/sort/src/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1529,7 +1529,7 @@ fn make_sort_mode_arg(mode: &'static str, short: char, help: String) -> Arg {
.action(ArgAction::SetTrue)
}

#[cfg(unix)]
#[cfg(all(unix, not(target_os = "fuchsia")))]
fn get_rlimit() -> UResult<usize> {
use rlimit::{Resource, getrlimit};

Expand All @@ -1540,12 +1540,12 @@ fn get_rlimit() -> UResult<usize> {
.map_err(|_| UUsageError::new(2, translate!("sort-failed-fetch-rlimit")))
}

#[cfg(unix)]
#[cfg(all(unix, not(target_os = "fuchsia")))]
pub(crate) fn fd_soft_limit() -> Option<usize> {
get_rlimit().ok()
}

#[cfg(not(unix))]
#[cfg(not(all(unix, not(target_os = "fuchsia"))))]
pub(crate) fn fd_soft_limit() -> Option<usize> {
None
}
Expand Down
4 changes: 3 additions & 1 deletion tests/uutests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ uucore = { workspace = true, features = [
"utmpx",
] }

[target.'cfg(all(unix, not(target_os = "fuchsia")))'.dependencies]
rlimit = { workspace = true }

[target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies]

[target.'cfg(unix)'.dependencies]
nix = { workspace = true, features = ["fs", "term"] }
rlimit = { workspace = true }
rustix = { workspace = true, features = ["pty", "termios"] }

[target.'cfg(any(target_os = "freebsd", target_os = "hurd", target_os = "linux", target_os = "android", target_os = "netbsd"))'.dependencies]
Expand Down
10 changes: 5 additions & 5 deletions tests/uutests/src/lib/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use nix::sys;
#[cfg(not(windows))]
use nix::sys::stat::{self, SFlag};
use pretty_assertions::assert_eq;
#[cfg(unix)]
#[cfg(all(unix, not(target_os = "fuchsia")))]
use rlimit::{Resource, setrlimit};
use std::borrow::Cow;
use std::collections::{BTreeMap, VecDeque};
Expand Down Expand Up @@ -1562,7 +1562,7 @@ pub struct UCommand {
stdout: Option<Stdio>,
stderr: Option<Stdio>,
bytes_into_stdin: Option<Vec<u8>>,
#[cfg(unix)]
#[cfg(all(unix, not(target_os = "fuchsia")))]
limits: Vec<(Resource, u64, u64)>,
#[cfg(unix)]
ignore_sigxfsz: bool,
Expand Down Expand Up @@ -1727,7 +1727,7 @@ impl UCommand {
self
}

#[cfg(unix)]
#[cfg(all(unix, not(target_os = "fuchsia")))]
pub fn limit(&mut self, resource: Resource, soft_limit: u64, hard_limit: u64) -> &mut Self {
self.limits.push((resource, soft_limit, hard_limit));
self
Expand Down Expand Up @@ -2086,7 +2086,7 @@ impl UCommand {
}
}

#[cfg(unix)]
#[cfg(all(unix, not(target_os = "fuchsia")))]
if !self.limits.is_empty() {
// just to be safe: move a copy of the limits list into the closure.
// this way the closure is fully self-contained.
Expand Down Expand Up @@ -3768,7 +3768,7 @@ mod tests {
.stdout_is("unlimited\nunlimited\n");
}

#[cfg(unix)]
#[cfg(all(unix, not(target_os = "fuchsia")))]
#[test]
fn test_application_of_process_resource_limits_limited_file_size() {
let unit_size_bytes = if cfg!(target_vendor = "apple") {
Expand Down
Loading