Skip to content

Commit 78b267d

Browse files
authored
Merge branch 'main' into head-continue-after-read-error
2 parents d7ff6b3 + 85a8175 commit 78b267d

9 files changed

Lines changed: 35 additions & 60 deletions

File tree

.github/workflows/ignore-intermittent.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@ tests/expand/bounded-memory
66
tests/pr/bounded-memory
77
tests/tail/inotify-dir-recreate
88
tests/tail/overlay-headers
9+
tests/tail/pid-pipe
910
tests/tail/retry
1011
tests/tail/tail-n0f
1112
tests/tail/pipe-f
1213
tests/timeout/timeout
1314
tests/tail/symlink
1415
tests/shuf/shuf-reservoir
1516
tests/sort/sort-stale-thread-mem
17+
tests/timeout/timeout-group
1618
tests/tty/tty-eof
1719
tests/misc/stdbuf
20+
tests/misc/tty-eof
1821
tests/misc/usage_vs_getopt
1922
tests/misc/tee
2023
tests/tail/follow-name

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ pub fn main() {
4444
// Allow this as we have a bunch of info in the comments
4545
#[allow(clippy::match_same_arms)]
4646
match krate.as_ref() {
47+
#[cfg(not(any(target_os = "linux", target_os = "android")))]
48+
"chcon" | "runcon" => {
49+
continue;
50+
}
4751
"default" | "macos" | "unix" | "windows" | "selinux" | "zip" | "clap_complete"
4852
| "clap_mangen" | "fluent_syntax" => continue, // common/standard feature names
4953
"nightly" | "test_unimplemented" | "expensive_tests" | "test_risky_names" => {

fuzz/Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/uu/sort/Cargo.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,11 @@ fluent = { workspace = true }
4848
foldhash = { workspace = true }
4949

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

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

56-
[target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies]
57-
nix = { workspace = true }
58-
5956
[target.'cfg(unix)'.dependencies]
6057
libc = { workspace = true }
6158

src/uu/sort/src/buffer_hint.rs

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -83,48 +83,23 @@ fn desired_file_buffer_bytes(total_bytes: u128) -> u128 {
8383
quarter.max(max)
8484
}
8585

86+
#[allow(
87+
clippy::unnecessary_wraps,
88+
reason = "fn sig must match on all platforms"
89+
)]
8690
fn physical_memory_bytes() -> Option<u128> {
87-
#[cfg(all(
88-
target_family = "unix",
89-
not(target_os = "redox"),
90-
any(target_os = "linux", target_os = "android")
91-
))]
91+
#[cfg(any(target_os = "linux", target_os = "android"))]
9292
{
93-
physical_memory_bytes_unix()
93+
Some(rustix::system::sysinfo().totalram as u128)
9494
}
9595

96-
#[cfg(any(
97-
not(target_family = "unix"),
98-
target_os = "redox",
99-
not(any(target_os = "linux", target_os = "android"))
100-
))]
96+
#[cfg(not(any(target_os = "linux", target_os = "android")))]
10197
{
10298
// No portable or safe API is available here to detect total physical memory.
10399
None
104100
}
105101
}
106102

107-
#[cfg(all(
108-
target_family = "unix",
109-
not(target_os = "redox"),
110-
any(target_os = "linux", target_os = "android")
111-
))]
112-
fn physical_memory_bytes_unix() -> Option<u128> {
113-
use nix::unistd::{SysconfVar, sysconf};
114-
115-
let pages = match sysconf(SysconfVar::_PHYS_PAGES) {
116-
Ok(Some(pages)) if pages > 0 => u128::try_from(pages).ok()?,
117-
_ => return None,
118-
};
119-
120-
let page_size = match sysconf(SysconfVar::PAGE_SIZE) {
121-
Ok(Some(page_size)) if page_size > 0 => u128::try_from(page_size).ok()?,
122-
_ => return None,
123-
};
124-
125-
Some(pages.saturating_mul(page_size))
126-
}
127-
128103
#[cfg(test)]
129104
mod tests {
130105
use super::*;

tests/by-util/test_ls.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
clippy::cast_possible_truncation
1111
)]
1212

13-
#[cfg(all(unix, feature = "chmod"))]
14-
use nix::unistd::{close, dup};
1513
use regex::Regex;
1614
#[cfg(unix)]
1715
use rlimit::Resource;
@@ -599,8 +597,8 @@ fn test_ls_io_errors() {
599597

600598
at.touch("some-dir4/bad-fd.txt");
601599
let fd1 = at.open("some-dir4/bad-fd.txt");
602-
let fd2 = dup(dbg!(&fd1)).unwrap();
603-
close(fd1).unwrap();
600+
let fd2 = rustix::io::dup(dbg!(&fd1)).unwrap();
601+
drop(fd1); //close
604602

605603
// on the mac and in certain Linux containers bad fds are typed as dirs,
606604
// however sometimes bad fds are typed as links and directory entry on links won't fail
@@ -644,7 +642,7 @@ fn test_ls_io_errors() {
644642
.arg(format!("/dev/fd/{}", fd2.as_raw_fd()))
645643
.succeeds();
646644

647-
let _ = close(fd2);
645+
drop(fd2); //close
648646
}
649647
}
650648

tests/by-util/test_sort.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,10 +1570,9 @@ fn test_wrong_args_exit_code() {
15701570
#[test]
15711571
#[cfg(unix)]
15721572
fn test_tmp_files_deleted_on_sigint() {
1573-
use std::{fs::read_dir, time::Duration};
1574-
1575-
use nix::{sys::signal, unistd::Pid};
15761573
use rand::{RngExt as _, SeedableRng, rngs::SmallRng};
1574+
use rustix::process::{Pid, Signal, kill_process};
1575+
use std::{fs::read_dir, time::Duration};
15771576

15781577
let (at, mut ucmd) = at_and_ucmd!();
15791578
at.mkdir("tmp_dir");
@@ -1609,7 +1608,7 @@ fn test_tmp_files_deleted_on_sigint() {
16091608
// `sort` should have created a temporary directory.
16101609
assert!(read_dir(at.plus("tmp_dir")).unwrap().next().is_some());
16111610
// kill sort with SIGINT
1612-
signal::kill(Pid::from_raw(child.id() as i32), signal::SIGINT).unwrap();
1611+
kill_process(Pid::from_raw(child.id() as i32).unwrap(), Signal::INT).unwrap();
16131612
// wait for `sort` to exit
16141613
child.wait().unwrap().code_is(2);
16151614
// `sort` should have deleted the temporary directory again.

tests/by-util/test_tail.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,16 @@
1313
clippy::cast_possible_truncation
1414
)]
1515

16+
use pretty_assertions::assert_eq;
17+
use rand::distr::Alphanumeric;
18+
use rstest::rstest;
1619
#[cfg(all(
1720
not(target_vendor = "apple"),
1821
not(target_os = "windows"),
1922
not(target_os = "android"),
2023
not(target_os = "freebsd")
2124
))]
22-
use nix::sys::signal::{Signal, kill};
23-
#[cfg(all(
24-
not(target_vendor = "apple"),
25-
not(target_os = "windows"),
26-
not(target_os = "android"),
27-
not(target_os = "freebsd")
28-
))]
29-
use nix::unistd::Pid;
30-
use pretty_assertions::assert_eq;
31-
use rand::distr::Alphanumeric;
32-
use rstest::rstest;
25+
use rustix::process::{Pid, Signal, kill_process};
3326
use std::char::from_digit;
3427
use std::fs::File;
3528
use std::io::Write;
@@ -790,7 +783,11 @@ fn test_follow_with_pid() {
790783
.stdout_only_fixture("foobar_follow_multiple_appended.expected");
791784

792785
// kill the dummy process and give tail time to notice this
793-
kill(Pid::from_raw(i32::try_from(pid).unwrap()), Signal::SIGUSR1).unwrap();
786+
kill_process(
787+
Pid::from_raw(i32::try_from(pid).unwrap()).unwrap(),
788+
Signal::USR1,
789+
)
790+
.unwrap();
794791
let _ = dummy.wait();
795792

796793
child.delay(DEFAULT_SLEEP_INTERVAL_MILLIS);
@@ -2770,7 +2767,11 @@ fn test_fifo_with_pid() {
27702767

27712768
child.make_assertion_with_delay(500).is_alive();
27722769

2773-
kill(Pid::from_raw(i32::try_from(pid).unwrap()), Signal::SIGUSR1).unwrap();
2770+
kill_process(
2771+
Pid::from_raw(i32::try_from(pid).unwrap()).unwrap(),
2772+
Signal::USR1,
2773+
)
2774+
.unwrap();
27742775
let _ = dummy.wait();
27752776

27762777
child

0 commit comments

Comments
 (0)