✅ Run the update test's copy of sleep as sleep

linux_names_a_replaced_running_binary_deleted copies /bin/sleep and runs the
copy. Where /bin/sleep is uutils' one binary of every utility, as on Ubuntu
26.04, it picks the utility by argv[0], and as `sleeper` it slept not at all:
on GitHub's ubuntu-26.04 runner the child was gone before the test read its
/proc entry. argv[0] is now `sleep`, which GNU's sleep ignores.
This commit is contained in:
Anees Iqbal committed 2026-12-03 15:48:28 -08:00
1 parent 344b120f6e
commit 837b29e48b
1 file changed
+6 -1
+6 -1
View File
@@ -541,17 +541,22 @@ mod tests {
#[cfg(target_os = "linux")]
#[test]
fn linux_names_a_replaced_running_binary_deleted() {
use std::os::unix::process::CommandExt;
let d = std::env::temp_dir().join(format!("reims-ctl-replaced-{}", std::process::id()));
let _ = std::fs::remove_dir_all(&d);
std::fs::create_dir_all(&d).unwrap();
let bin = d.join("sleeper");
// Run as `sleep` whatever the copy is named: where /bin/sleep is uutils' one binary of every
// utility (Ubuntu 26.04's coreutils), it picks the utility by argv[0], and as `sleeper` it
// ran no sleep: the child was gone before this test read its /proc entry, on GitHub's
// ubuntu-26.04 runner (2026-12-03).
std::fs::copy("/bin/sleep", &bin).unwrap();
// The copy's write handle is closed, but another test's child forked while it was open
// holds it until that child execs, and an exec of a file open for writing fails with
// ETXTBSY: spawn again until that child has let go of it.
let busy = std::time::Instant::now();
let mut child = loop {
match Command::new(&bin).arg("30").spawn() {
match Command::new(&bin).arg0("sleep").arg("30").spawn() {
Err(e)
if e.raw_os_error() == Some(libc::ETXTBSY)
&& busy.elapsed() < std::time::Duration::from_secs(10) =>