Watch
0
0
Fork
You've already forked hyperhive
0

meta lock waiters keep their queue place; deadlines cover pin_agent git and kill the whole process group

This commit is contained in:
atlas 2026-10-20 00:23:39 +02:00 • committed by mara
commit 161dd8c44b
4 changed files with 138 additions and 51 deletions

View file

@ -475,14 +475,18 @@ async fn a_systemctl_answer_inside_the_bound_passes_through() {
}
/// A child that outlives the deadline yields an error naming the command and
/// the deadline, and is killed rather than orphaned.
/// the deadline, and the child and its grandchild are both killed rather than
/// orphaned.
#[tokio::test]
async fn run_with_deadline_times_out_and_kills_the_child() {
async fn run_with_deadline_times_out_and_kills_the_process_group() {
let dir = tempfile::tempdir().expect("tempdir");
let pidfile = dir.path().join("pid");
let (shpid, sleeppid) = (dir.path().join("sh.pid"), dir.path().join("sleep.pid"));
let mut cmd = tokio::process::Command::new("sh");
cmd.arg("-c")
.arg(format!("echo $$ > {}; exec sleep 30", pidfile.display()));
cmd.arg("-c").arg(format!(
"echo $$ > {}; sleep 300 & echo $! > {}; wait",
shpid.display(),
sleeppid.display()
));
let err = run_with_deadline(
&mut cmd,
std::time::Duration::from_millis(500),
@ -493,18 +497,23 @@ async fn run_with_deadline_times_out_and_kills_the_child() {
let msg = format!("{err:#}");
assert!(msg.contains("fake fetch timed out after 0.5s"), "{msg}");
let pid = std::fs::read_to_string(&pidfile)
.expect("child wrote its pid before the deadline")
.trim()
.to_owned();
let proc = std::path::PathBuf::from("/proc").join(&pid);
for _ in 0..100 {
if !proc.exists() {
return;
for file in [&shpid, &sleeppid] {
// The pid file proves the process existed before the kill.
let pid = std::fs::read_to_string(file)
.expect("process wrote its pid before the deadline")
.trim()
.to_owned();
let proc = std::path::PathBuf::from("/proc").join(&pid);
let mut gone = false;
for _ in 0..100 {
if !proc.exists() {
gone = true;
break;
}
tokio::time::sleep(std::time::Duration::from_millis(50)).await;
}
tokio::time::sleep(std::time::Duration::from_millis(50)).await;
assert!(gone, "pid {pid} ({}) still running", file.display());
}
panic!("child {pid} still running after the deadline dropped its future");
}
/// Presence control for the timeout test: a child that finishes in time