use crate::child::owned::teardown::Disposition;
use crate::child::Child;
use crate::error::ChildFate;
use crate::identity::Liveness;
use crate::log_capture::warns_since;
use crate::os_process::fake::FakeProcess;
#[cfg(target_os = "linux")]
use crate::test_child::Console;
use crate::test_child::{held_uncontained_blocker, held_uncontained_blocker_reporting, tear_down_holding};
fn refuse_the_kill(child: &mut Child) -> FakeProcess {
child
.proc
.script_over(|f| f.signals([Err(std::io::Error::from(std::io::ErrorKind::PermissionDenied))]))
}
#[skuld::test]
fn a_refused_kill_hands_the_child_back_and_says_so() {
crate::log_capture::install();
let (mut child, stdin) = held_uncontained_blocker(true);
let id = child.id().expect(crate::test_child::IDENTITY_READ);
refuse_the_kill(&mut child);
let mark = crate::log_capture::mark();
let (fate, handed_back) = tear_down_holding(child, stdin, Disposition::HandBack);
assert_eq!(fate, ChildFate::Running { id: Some(id) });
assert_eq!(handed_back.unreaped().pid(), Some(id.pid()));
assert_eq!(handed_back.unreaped().id(), Some(id));
let warns = warns_since(mark, "");
assert_eq!(warns.len(), 1, "{warns:?}");
assert!(
warns[0].starts_with("teardown after a failed run: ")
&& warns[0].contains(&id.pid().to_string())
&& warns[0].contains("handed back to the caller")
&& !warns[0].contains("leaving it running"),
"{warns:?}"
);
handed_back.wait();
}
#[skuld::test]
fn the_unreaped_a_child_hands_back_does_what_its_spawns_policy_says_on_drop() {
use crate::child::spawn::policy::SpawnPolicy;
use crate::signal::Sig;
let (mut child, stdin) = held_uncontained_blocker(true);
child.policy = SpawnPolicy::LET_GO;
let refused = || Err(std::io::Error::from(std::io::ErrorKind::PermissionDenied));
let fake = child.proc.script_over(|f| f.signals([refused(), refused()]));
let (_, handed_back) = tear_down_holding(child, stdin, Disposition::HandBack);
handed_back.unreaped();
assert_eq!(fake.signal_calls(), [Sig::Kill], "the teardown's own kill");
drop(handed_back);
assert_eq!(fake.signal_calls(), [Sig::Kill, Sig::Kill], "the drop's kill");
}
#[skuld::test]
fn the_unreaped_a_child_without_a_front_hands_back_is_sent_the_drops_kill() {
use crate::child::spawn::policy::SpawnPolicy;
use crate::elevation::elevation_tests::{report, VIAS_WITHOUT_A_FRONT};
use crate::signal::Sig;
for via in VIAS_WITHOUT_A_FRONT {
let (mut child, stdin) = held_uncontained_blocker_reporting(true, Some(report(via.clone())));
child.policy = SpawnPolicy::LET_GO;
let refused = || Err(std::io::Error::from(std::io::ErrorKind::PermissionDenied));
let fake = child.proc.script_over(|f| f.signals([refused(), refused()]));
let (_, handed_back) = tear_down_holding(child, stdin, Disposition::HandBack);
handed_back.unreaped();
assert_eq!(fake.signal_calls(), [Sig::Kill], "{via:?}: the teardown's own kill");
drop(handed_back);
assert_eq!(fake.signal_calls(), [Sig::Kill, Sig::Kill], "{via:?}: the drop's kill");
}
}
#[cfg(unix)]
#[skuld::test]
fn a_refused_kill_is_left_when_the_caller_leaves_it() {
crate::log_capture::install();
let (mut child, stdin) = held_uncontained_blocker(true);
let id = child.id().expect(crate::test_child::IDENTITY_READ);
refuse_the_kill(&mut child);
let mark = crate::log_capture::mark();
let (fate, handed_back) = tear_down_holding(child, stdin, Disposition::Leave);
assert_eq!(fate, ChildFate::Running { id: Some(id) });
assert!(handed_back.is_none(), "the teardown handed the child back");
let warns = warns_since(mark, "");
assert_eq!(warns.len(), 1, "{warns:?}");
assert!(
warns[0].starts_with("teardown after a failed run: ") && warns[0].contains("leaving it running"),
"{warns:?}"
);
drop(handed_back);
crate::test_child::wait_until_zombie(id.pid());
}
#[skuld::test]
fn a_child_that_opted_out_is_not_handed_back() {
let (child, stdin) = held_uncontained_blocker(false);
let id = child.id().expect(crate::test_child::IDENTITY_READ);
let (fate, handed_back) = tear_down_holding(child, stdin, Disposition::HandBack);
assert_eq!(fate, ChildFate::Running { id: Some(id) });
assert!(handed_back.is_none(), "the teardown handed the child back");
assert_eq!(id.is_alive(), Liveness::Alive, "nothing was sent to it");
}
#[skuld::test]
fn a_disarmed_teardown_names_the_fate_the_peek_at_the_root_shows() {
use crate::os_process::child::{ExitRecord, Foreign, PeekOutcome};
use crate::os_process::fake::PeekAnswer;
crate::log_capture::install();
#[cfg(unix)]
let exacts = [true, false];
#[cfg(not(unix))]
let exacts = [true];
type Row = (&'static str, fn() -> PeekAnswer, Option<fn(bool) -> ChildFate>, bool);
let rows: [Row; 5] = [
(
"an exit",
|| Ok(PeekOutcome::Exit(ExitRecord::Status(Default::default()))),
Some(|consumes| if consumes { ChildFate::Reaped } else { ChildFate::Killed }),
false,
),
(
"a foreign reap: gone",
|| Ok(PeekOutcome::Foreign(Foreign::Gone)),
Some(|_| ChildFate::Gone),
false,
),
(
"a foreign reap: another process",
|| Ok(PeekOutcome::Foreign(Foreign::Other)),
Some(|_| ChildFate::Gone),
false,
),
("no exit", || Ok(PeekOutcome::Running), None, false),
(
"a failed peek",
|| Err(std::io::Error::other("forced peek failure")),
None,
true,
),
];
for exact in exacts {
for (name, answer, expected, logged) in &rows {
let (mut child, stdin) = held_uncontained_blocker(false);
let id = child.id().expect(crate::test_child::IDENTITY_READ);
child.proc.script_over(|fake| {
let fake = fake.peeks([answer()]);
#[cfg(unix)]
let fake = fake.with_exact_consume(exact);
fake
});
let mark = crate::log_capture::mark();
let (fate, handed_back) = tear_down_holding(child, stdin, Disposition::Leave);
let want = expected.map_or(ChildFate::Running { id: Some(id) }, |fate_of| fate_of(exact));
assert_eq!(fate, want, "{name} (exact consume: {exact})");
assert!(handed_back.is_none(), "{name}: the teardown handed the child back");
let said = crate::log_capture::records_since_on_current_thread(mark, "could not look at it");
match logged {
true => {
let [(level, text)] = &said[..] else {
panic!("{name}: one record expected: {said:?}");
};
assert_eq!(*level, log::Level::Debug, "{text}");
assert!(text.contains("forced peek failure"), "{text}");
}
false => assert_eq!(said, [], "{name} logged"),
}
}
}
}
#[cfg(unix)]
#[skuld::test]
fn a_disarmed_teardown_of_an_exited_child_the_wait_never_saw_does_not_say_it_runs() {
let (child, stdin) = held_uncontained_blocker(false);
let pid = child.pid();
drop(stdin);
crate::test_child::wait_until_zombie(pid);
let (fate, handed_back) = tear_down_holding(child, (), Disposition::Leave);
#[cfg(target_os = "linux")]
assert_eq!(fate, ChildFate::Reaped);
#[cfg(target_os = "macos")]
{
assert_eq!(fate, ChildFate::Killed);
crate::test_child::reaped_elsewhere::reap_behind(pid);
}
assert!(handed_back.is_none(), "the teardown handed the child back");
}
#[cfg(unix)]
#[skuld::test]
fn a_refused_kill_of_a_child_that_has_exited_hands_nothing_back() {
let (mut child, stdin) = held_uncontained_blocker(true);
drop(stdin);
crate::test_child::wait_until_zombie(child.pid());
refuse_the_kill(&mut child);
let (fate, handed_back) = tear_down_holding(child, (), Disposition::HandBack);
assert_eq!(fate, ChildFate::Reaped);
assert!(handed_back.is_none(), "the teardown handed the child back");
}
#[cfg(unix)]
#[skuld::test]
fn a_refused_kill_with_a_failed_look_hands_the_child_back() {
use crate::os_process::fake::ReapAnswer;
let (mut child, stdin) = held_uncontained_blocker(true);
child.proc.script_over(|f| {
f.signals([Err(std::io::Error::from(std::io::ErrorKind::PermissionDenied))])
.reaps([ReapAnswer::Err(std::io::ErrorKind::Other)])
});
let (fate, handed_back) = tear_down_holding(child, stdin, Disposition::HandBack);
assert_eq!(fate, ChildFate::Unknown);
handed_back.unreaped();
handed_back.wait();
}
#[cfg(unix)]
#[skuld::test]
fn a_delivered_kill_whose_wait_failed_hands_the_child_back() {
use crate::os_process::fake::ReapAnswer;
use crate::signal::Sent;
let (mut child, stdin) = held_uncontained_blocker(true);
child.proc.script_over(|f| {
f.signals([Ok(Sent::Delivered)])
.reaps([ReapAnswer::Err(std::io::ErrorKind::Other)])
});
let (fate, handed_back) = tear_down_holding(child, stdin, Disposition::HandBack);
assert_eq!(fate, ChildFate::Killed);
handed_back.unreaped();
handed_back.wait();
}
#[cfg(unix)]
#[skuld::test]
fn a_child_reaped_elsewhere_is_not_handed_back() {
use crate::os_process::child::Foreign;
use crate::os_process::fake::ReapAnswer;
use crate::signal::Sent;
let refused = || Err(std::io::Error::from(std::io::ErrorKind::PermissionDenied));
for (kill, fate) in [(refused(), ChildFate::Gone), (Ok(Sent::Delivered), ChildFate::Killed)] {
let (mut child, stdin) = held_uncontained_blocker(true);
child
.proc
.script_over(|f| f.signals([kill]).reaps([ReapAnswer::Foreign(Foreign::Gone)]));
let (torn, handed_back) = tear_down_holding(child, stdin, Disposition::HandBack);
assert_eq!(torn, fate);
assert!(
handed_back.is_none(),
"the teardown handed back a child reaped elsewhere"
);
}
}
#[cfg(target_os = "linux")]
#[skuld::test]
fn a_handed_back_process_group_child_has_its_group_killed_first() {
use crate::{ContainMode, Containment};
let _old_kernel = crate::containment::unix::fault::refuse_pidfd_group_flag();
let recorder = crate::containment::unix::fault::record_kill_group();
let (stdin, writer) = crate::test_child::held_writer_stdin();
let mut cmd = crate::test_child::command(Console::Hidden);
cmd.args(crate::test_child::BLOCKER_ARGV.iter().copied());
cmd.stdin(stdin).expect("set stdin");
cmd.contain_with(ContainMode::Session);
let mut child = cmd.spawn().expect("spawn");
assert_eq!(child.containment(), Containment::Session);
let id = child.id().expect(crate::test_child::IDENTITY_READ);
refuse_the_kill(&mut child);
let (fate, handed_back) = tear_down_holding(child, writer, Disposition::HandBack);
recorder.assert_killed_only(id.pid() as i32);
assert_eq!(fate, ChildFate::Running { id: Some(id) });
handed_back.unreaped();
handed_back.wait();
}
#[cfg(windows)]
#[skuld::test]
fn a_job_contained_child_whose_kill_is_refused_and_look_shows_the_exit_is_not_handed_back() {
use crate::os_process::child::ExitRecord;
use crate::os_process::fake::ReapAnswer;
let (mut child, stdin, _id) = crate::test_child::live_blocker();
child.proc.script_over(|f| {
f.signals([Err(std::io::Error::from(std::io::ErrorKind::PermissionDenied))])
.reaps([ReapAnswer::Exited(ExitRecord::Status(Default::default()))])
});
let (fate, handed_back) = tear_down_holding(child, stdin, Disposition::HandBack);
assert_eq!(fate, ChildFate::Reaped);
assert!(handed_back.is_none());
}
#[cfg(unix)]
fn a_running_front() -> (Child, crate::PipeWriter) {
use crate::elevation::{Backend, ElevatedVia};
crate::log_capture::install();
crate::child::front_kill_tests::spawn_as(
crate::child::front_kill_tests::cat(),
ElevatedVia::Wrapped(Backend::Sudo),
)
}
#[cfg(unix)]
#[track_caller]
fn assert_front_handed_back(
id: crate::identity::ProcessId,
mark: usize,
fate: ChildFate,
handed_back: crate::test_child::HandedBack<crate::PipeWriter>,
) {
assert_eq!(fate, ChildFate::Running { id: Some(id) });
assert_eq!(handed_back.unreaped().pid(), Some(id.pid()));
assert_eq!(handed_back.unreaped().id(), Some(id));
assert_eq!(id.is_alive(), Liveness::Alive, "a front is sent nothing");
let warns = warns_since(mark, "");
assert_eq!(warns.len(), 1, "{warns:?}");
assert!(
warns[0].starts_with(&format!(
"teardown after a failed run: elevation front pid {} is running and unreaped",
id.pid()
)) && warns[0].contains("handed back to the caller in the error")
&& !warns[0].contains("left running"),
"{warns:?}"
);
assert!(handed_back.wait().success(), "a front is sent nothing");
}
#[cfg(unix)]
#[skuld::test]
fn a_running_elevation_front_is_handed_back() {
let (child, stdin) = a_running_front();
let id = child.id().expect(crate::test_child::IDENTITY_READ);
let mark = crate::log_capture::mark();
let (fate, handed_back) = tear_down_holding(child, stdin, Disposition::HandBack);
assert_front_handed_back(id, mark, fate, handed_back);
}
#[cfg(unix)]
#[skuld::test]
fn an_elevation_front_sent_no_kill_has_the_refusal_among_its_failures() {
let (child, stdin) = a_running_front();
let (_, failures, handed_back) = crate::test_child::tear_down_holding_failures(child, stdin, Disposition::HandBack);
let failures = failures.expect("the refusal is the teardown's failure");
assert_eq!(failures.iter().len(), 1, "{failures:?}");
assert!(
matches!(
&**failures.first(),
crate::error::Error::Elevation {
kind: crate::error::ElevationErrorKind::Unkillable,
..
}
),
"{failures:?}"
);
handed_back.unreaped();
handed_back.wait();
}
#[cfg(unix)]
#[skuld::test]
fn an_elevation_front_is_left_when_the_caller_leaves_it() {
let (child, stdin) = a_running_front();
let id = child.id().expect(crate::test_child::IDENTITY_READ);
let mark = crate::log_capture::mark();
let (fate, handed_back) = tear_down_holding(child, stdin, Disposition::Leave);
assert_eq!(fate, ChildFate::Running { id: Some(id) });
assert!(handed_back.is_none(), "the teardown handed the child back");
let warns = warns_since(mark, "");
assert_eq!(warns.len(), 1, "{warns:?}");
assert!(
warns[0].starts_with("teardown after a failed run: ") && warns[0].contains("is left running and unreaped"),
"{warns:?}"
);
drop(handed_back);
crate::test_child::wait_until_zombie(id.pid());
}
#[cfg(unix)]
#[skuld::test]
fn an_elevation_front_whose_look_failed_is_handed_back() {
use crate::os_process::fake::ReapAnswer;
let (mut child, stdin) = a_running_front();
child
.proc
.script_over(|f| f.reaps([ReapAnswer::Err(std::io::ErrorKind::Other)]));
let (fate, handed_back) = tear_down_holding(child, stdin, Disposition::HandBack);
assert_eq!(fate, ChildFate::Unknown);
handed_back.unreaped();
handed_back.wait();
}
#[cfg(unix)]
#[skuld::test]
fn an_elevation_front_reaped_elsewhere_is_not_handed_back() {
use crate::os_process::child::Foreign;
use crate::os_process::fake::ReapAnswer;
let (mut child, stdin) = a_running_front();
child
.proc
.script_over(|f| f.reaps([ReapAnswer::Foreign(Foreign::Gone)]));
let (fate, handed_back) = tear_down_holding(child, stdin, Disposition::HandBack);
assert_eq!(fate, ChildFate::Gone);
assert!(
handed_back.is_none(),
"the teardown handed back a front reaped elsewhere"
);
}
#[cfg(unix)]
#[skuld::test]
fn an_elevation_front_that_has_exited_is_reaped_not_handed_back() {
let (child, stdin) = a_running_front();
drop(stdin);
crate::test_child::wait_until_zombie(child.pid());
let mark = crate::log_capture::mark();
let (fate, handed_back) = tear_down_holding(child, (), Disposition::HandBack);
assert_eq!(fate, ChildFate::Reaped);
assert!(handed_back.is_none(), "the teardown handed the child back");
assert_eq!(warns_since(mark, ""), Vec::<String>::new());
}
#[cfg(target_os = "linux")]
mod in_a_cgroup {
use crate::PipeWriter;
use std::path::Path;
use super::{assert_front_handed_back, refuse_the_kill, warns_since};
use crate::child::front_cgroup_tests::{cgroup_dir_of, in_cgroup, move_out_of_its_leaf, SUDO};
use crate::child::front_kill_tests::{cat, spawn_as};
use crate::child::owned::teardown::Disposition;
use crate::child::Child;
use crate::error::ChildFate;
use crate::identity::Existence;
use crate::os_process::fake::ReapAnswer;
use crate::test_child::{tear_down_holding, Console};
use crate::test_groups::{cgroup, Group};
use crate::{ContainMode, Containment};
fn blocker_in_a_leaf() -> (Child, PipeWriter) {
let (stdin, writer) = crate::test_child::held_writer_stdin();
let mut cmd = crate::test_child::command(Console::Hidden);
cmd.args(crate::test_child::BLOCKER_ARGV.iter().copied());
cmd.stdin(stdin).expect("set stdin");
cmd.contain_with(ContainMode::Strongest);
let child = cmd.spawn().expect("spawn");
assert_eq!(child.containment(), Containment::CgroupV2);
(child, writer)
}
#[skuld::test]
fn a_handed_back_child_does_not_hold_up_its_leaf(#[fixture(cgroup)] _group: &Group) {
use crate::wait::block_probe::on_blocking;
let (mut child, stdin) = blocker_in_a_leaf();
let pid = child.pid();
let leaf = cgroup_dir_of(pid);
move_out_of_its_leaf(pid);
refuse_the_kill(&mut child);
let release_at_the_block = on_blocking(move || drop(stdin));
let (fate, handed_back) = tear_down_holding(child, release_at_the_block, Disposition::HandBack);
assert!(
matches!(fate, ChildFate::Running { .. }),
"the call blocked on the root, which the hook ended: {fate:?}"
);
handed_back.unreaped();
assert!(!Path::new(&leaf).exists(), "the leaf {leaf} was removed by the call");
handed_back.wait();
}
#[skuld::test]
fn a_front_outside_its_leaf_is_handed_back_after_its_leaf_is_gone(#[fixture(cgroup)] _group: &Group) {
crate::log_capture::install();
let (child, stdin) = spawn_as(in_cgroup(cat()), SUDO);
let id = child.id().expect(crate::test_child::IDENTITY_READ);
let leaf = cgroup_dir_of(id.pid());
move_out_of_its_leaf(id.pid());
let mark = crate::log_capture::mark();
let (fate, handed_back) = tear_down_holding(child, stdin, Disposition::HandBack);
assert!(!Path::new(&leaf).exists(), "the leaf {leaf} was removed by the call");
assert_front_handed_back(id, mark, fate, handed_back);
}
#[skuld::test]
fn a_front_that_leaves_its_leaf_during_the_kill_is_handed_back(#[fixture(cgroup)] _group: &Group) {
crate::log_capture::install();
let (child, stdin) = spawn_as(in_cgroup(cat()), SUDO);
let id = child.id().expect(crate::test_child::IDENTITY_READ);
let leaf = cgroup_dir_of(id.pid());
let pid = id.pid();
let _moving = crate::containment::cgroup::fault::set_before_kill_write(move || move_out_of_its_leaf(pid));
let mark = crate::log_capture::mark();
let (fate, handed_back) = tear_down_holding(child, stdin, Disposition::HandBack);
assert!(!Path::new(&leaf).exists(), "the leaf {leaf} was removed by the call");
assert_front_handed_back(id, mark, fate, handed_back);
}
#[skuld::test]
fn a_front_the_leafs_kill_missed_has_the_refusal_among_its_failures(#[fixture(cgroup)] _group: &Group) {
let (child, stdin) = spawn_as(in_cgroup(cat()), SUDO);
let pid = child.pid();
let _moving = crate::containment::cgroup::fault::set_before_kill_write(move || move_out_of_its_leaf(pid));
let (_, failures, handed_back) =
crate::test_child::tear_down_holding_failures(child, stdin, Disposition::HandBack);
let failures = failures.expect("the refusal is the teardown's failure");
assert_eq!(failures.iter().len(), 1, "{failures:?}");
let refusal = failures.first().to_string();
assert!(
matches!(
&**failures.first(),
crate::error::Error::Elevation {
kind: crate::error::ElevationErrorKind::Unkillable,
..
}
) && refusal.contains("left the cgroup before its kill"),
"{failures:?}"
);
handed_back.unreaped();
handed_back.wait();
}
#[skuld::test]
fn a_front_whose_place_cannot_be_read_is_handed_back(#[fixture(cgroup)] _group: &Group) {
crate::log_capture::install();
let (mut child, stdin) = spawn_as(in_cgroup(cat()), SUDO);
let id = child.id().expect(crate::test_child::IDENTITY_READ);
child.proc.script_over(|fake| fake.reaps([ReapAnswer::Running]));
let mark = crate::log_capture::mark();
let (fate, handed_back) = {
let _unreadable = crate::containment::cgroup::fault::fail_pidfd_info();
tear_down_holding(child, stdin, Disposition::HandBack)
};
assert_eq!(fate, ChildFate::Running { id: Some(id) });
assert_eq!(handed_back.unreaped().id(), Some(id));
let warns = warns_since(mark, "");
assert_eq!(warns.len(), 1, "{warns:?}");
assert!(
warns[0].starts_with(&format!(
"teardown after a failed run: elevation front pid {} is running and unreaped",
id.pid()
)) && warns[0].contains("cannot be read")
&& warns[0].contains("handed back to the caller in the error"),
"{warns:?}"
);
handed_back.wait();
}
#[skuld::test]
fn a_front_whose_subtree_cannot_be_read_is_handed_back(#[fixture(cgroup)] _group: &Group) {
crate::log_capture::install();
let (child, stdin) = spawn_as(in_cgroup(cat()), SUDO);
let id = child.id().expect(crate::test_child::IDENTITY_READ);
move_out_of_its_leaf(id.pid());
let mark = crate::log_capture::mark();
let (fate, handed_back) = {
let _unreadable = crate::containment::cgroup::fault::fail_subtree(libc::EIO);
tear_down_holding(child, stdin, Disposition::HandBack)
};
assert_front_handed_back(id, mark, fate, handed_back);
}
#[skuld::test]
fn a_refused_kill_of_a_child_the_leaf_killed_is_reaped_not_handed_back(#[fixture(cgroup)] _group: &Group) {
crate::log_capture::install();
let (mut child, stdin) = blocker_in_a_leaf();
let id = child.id().expect(crate::test_child::IDENTITY_READ);
refuse_the_kill(&mut child);
let mark = crate::log_capture::mark();
let (fate, handed_back) = tear_down_holding(child, stdin, Disposition::HandBack);
assert_eq!(fate, ChildFate::Reaped);
assert!(handed_back.is_none(), "the teardown handed the child back");
assert_eq!(id.exists(), Existence::Gone, "the root was reaped, not left a zombie");
assert_eq!(warns_since(mark, ""), Vec::<String>::new());
}
#[skuld::test]
fn dropping_a_child_whose_kill_is_refused_but_whose_leaf_killed_it_reaps_it(#[fixture(cgroup)] _group: &Group) {
crate::log_capture::install();
let (mut child, stdin) = blocker_in_a_leaf();
let id = child.id().expect(crate::test_child::IDENTITY_READ);
refuse_the_kill(&mut child);
let mark = crate::log_capture::mark();
drop(child);
assert_eq!(id.exists(), Existence::Gone, "the root was reaped, not left a zombie");
assert_eq!(warns_since(mark, ""), Vec::<String>::new());
drop(stdin);
}
#[skuld::test]
fn a_handed_back_child_whose_leaf_cannot_kill_returns_and_logs_the_leaf(#[fixture(cgroup)] _group: &Group) {
crate::log_capture::install();
let (mut child, stdin) = blocker_in_a_leaf();
let leaf = cgroup_dir_of(child.pid());
refuse_the_kill(&mut child);
let mark = crate::log_capture::mark();
let (fate, handed_back) = {
let _failing = crate::containment::cgroup::fault::fail_kill_writes();
tear_down_holding(child, stdin, Disposition::HandBack)
};
assert!(matches!(fate, ChildFate::Running { .. }), "{fate:?}");
handed_back.unreaped();
let warns = warns_since(mark, "");
assert!(
warns.iter().any(|w| w.contains(&leaf) && w.contains("was not removed")),
"the leaf left behind is named: {warns:?}"
);
handed_back.wait();
std::fs::remove_dir(&leaf).expect("remove the leaf the call gave up");
}
}