#[cfg(unix)]
use crate::child::spawn::fault::{release_between_kill_and_wait, TeardownBlocker};
use crate::test_child::Console;
#[cfg(target_os = "linux")]
use crate::test_groups::{cgroup, Group};
use crate::tokio::child::{fault, Child};
fn blocker() -> (Child, crate::tokio::ChildStdin) {
let mut cmd = crate::test_child::tokio_command(Console::Hidden);
#[cfg(unix)]
cmd.args(crate::test_child::BLOCKER_ARGV.iter().copied());
#[cfg(windows)]
cmd.args([crate::test_child::windows_more()]);
cmd.stdin(crate::Stdio::pipe()).expect("set stdin pipe");
cmd.stdout(crate::Stdio::null()).expect("set stdout");
let mut child = cmd.spawn().expect("spawn");
let stdin = child.stdin().expect("piped stdin");
(child, stdin)
}
#[cfg(unix)]
pub(crate) fn released_blocker() -> (Child, TeardownBlocker) {
let (child, stdin) = blocker();
(child, release_between_kill_and_wait(stdin))
}
#[cfg(windows)]
pub(crate) struct TerminatedBlocker {
stdin: std::cell::Cell<Option<crate::tokio::ChildStdin>>,
process: std::os::windows::io::OwnedHandle,
}
#[cfg(windows)]
impl TerminatedBlocker {
pub(crate) fn assert_killed(&self) {
use std::os::windows::io::AsRawHandle as _;
use windows::Win32::Foundation::{HANDLE, WAIT_OBJECT_0};
use windows::Win32::System::Threading::{GetExitCodeProcess, WaitForSingleObject, INFINITE};
drop(self.stdin.take());
let process = HANDLE(self.process.as_raw_handle());
let waited = unsafe { WaitForSingleObject(process, INFINITE) };
assert_eq!(waited, WAIT_OBJECT_0, "wait for the root's exit");
let mut code = 0u32;
unsafe { GetExitCodeProcess(process, &mut code) }.expect("read the root's exit code");
assert_eq!(
code, 1,
"the drop must terminate the root (`TerminateProcess` exits 1), not leave it to exit on its own (0)"
);
}
}
#[cfg(windows)]
pub(crate) fn released_blocker() -> (Child, TerminatedBlocker) {
use std::os::windows::io::{FromRawHandle as _, OwnedHandle};
use windows::Win32::System::Threading::{OpenProcess, PROCESS_QUERY_LIMITED_INFORMATION, PROCESS_SYNCHRONIZE};
let (child, stdin) = blocker();
let process = unsafe {
OpenProcess(
PROCESS_SYNCHRONIZE | PROCESS_QUERY_LIMITED_INFORMATION,
false,
child.pid(),
)
}
.expect("open the root");
let process = unsafe { OwnedHandle::from_raw_handle(process.0) };
(
child,
TerminatedBlocker {
stdin: std::cell::Cell::new(Some(stdin)),
process,
},
)
}
#[cfg(target_os = "linux")]
use crate::containment::cgroup::test_support::alone;
#[cfg(target_os = "linux")]
use crate::test_child::fixture_path;
#[cfg(target_os = "linux")]
pub(crate) mod linux {
use std::os::fd::{AsFd, OwnedFd};
use super::Child;
use crate::containment::cgroup::fault as leaf_fault;
use crate::containment::cgroup::test_support::{entered_leaf_at, FakeLeaf};
use crate::containment::{Attached, Containment};
pub(in crate::tokio::child) fn contained_by(
mut child: Child,
leaf: crate::containment::cgroup::CgroupLeaf,
) -> Child {
child.os.attached = Attached::Cgroup(leaf);
child.containment = Containment::CgroupV2;
child
}
pub(in crate::tokio::child) fn fake_leaf(
name: &str,
populated: bool,
) -> (FakeLeaf, crate::containment::cgroup::CgroupLeaf) {
crate::log_capture::install();
let fake = FakeLeaf::new(name, populated);
let (path, events) = (fake.leaf.clone(), fake.events.clone());
leaf_fault::set_rmdir_hook(move |_| FakeLeaf::rmdir(&path, &events));
let leaf = entered_leaf_at(fake.leaf.clone());
(fake, leaf)
}
#[derive(Debug, PartialEq, Eq)]
pub(crate) enum Ended {
Exited(i32),
Signalled(i32),
ReapedWhileStdinOpen,
}
pub(crate) struct Pidfd(OwnedFd);
impl Pidfd {
pub(crate) fn of(child: &Child) -> Pidfd {
let pid = rustix::process::Pid::from_raw(child.pid() as i32).expect("a positive pid");
Pidfd(rustix::process::pidfd_open(pid, rustix::process::PidfdFlags::empty()).expect("pidfd_open"))
}
pub(super) fn reaped(&self) -> bool {
loop {
match rustix::process::waitid(
rustix::process::WaitId::PidFd(self.0.as_fd()),
rustix::process::WaitIdOptions::EXITED
| rustix::process::WaitIdOptions::NOHANG
| rustix::process::WaitIdOptions::NOWAIT,
) {
Ok(_) => return false,
Err(rustix::io::Errno::CHILD) => return true,
Err(rustix::io::Errno::INTR) => {}
Err(e) => panic!("waitid on the root's pidfd: {e}"),
}
}
}
pub(crate) fn ended_after_closing(&self, release: impl Sized) -> Ended {
debug_assert!(
std::env::var_os("COSCA_TEST_ALONE").is_some(),
"`ended_after_closing` is exact only in a process running this test alone (`alone()`): \
tokio's orphan queue is process-global"
);
let reaped_while_open = self.reaped();
drop(release);
if reaped_while_open {
return Ended::ReapedWhileStdinOpen;
}
loop {
let status = rustix::process::waitid(
rustix::process::WaitId::PidFd(self.0.as_fd()),
rustix::process::WaitIdOptions::EXITED | rustix::process::WaitIdOptions::NOWAIT,
);
match status {
Ok(Some(status)) => {
return match status.terminating_signal() {
Some(signal) => Ended::Signalled(signal),
None => Ended::Exited(status.exit_status().expect("exited")),
}
}
Ok(None) => unreachable!("a blocking waitid returns a status"),
Err(rustix::io::Errno::INTR) => {}
Err(e) => panic!("waitid on the root's pidfd: {e}"),
}
}
}
}
pub(super) fn kill_file(fake: &FakeLeaf) -> Vec<u8> {
std::fs::read(fake.leaf.join("cgroup.kill")).expect("read cgroup.kill")
}
pub(in crate::tokio::child) fn dropped(child: Child, needle: &str) -> (Vec<String>, Vec<log::Level>) {
let mark = crate::log_capture::mark();
leaf_fault::record_leaf_steps();
drop(child);
let steps = leaf_fault::take_leaf_steps();
leaf_fault::take_rmdir_hook();
(steps, crate::log_capture::levels_since(mark, needle))
}
}
#[cfg(target_os = "linux")]
fn thread_ids() -> std::collections::BTreeSet<String> {
std::fs::read_dir("/proc/self/task")
.expect("list /proc/self/task")
.map(|entry| entry.expect("a task entry").file_name().to_string_lossy().into_owned())
.collect()
}
#[cfg(target_os = "linux")]
#[skuld::test]
async fn an_async_drop_starts_no_thread() {
if !alone(fixture_path!(an_async_drop_starts_no_thread)) {
return;
}
let (child, teardown) = released_blocker();
let before = thread_ids();
drop(child);
let started: Vec<_> = thread_ids().difference(&before).cloned().collect();
assert!(started.is_empty(), "a drop started threads: {started:?}");
teardown.assert_killed();
}
#[cfg(target_os = "linux")]
#[skuld::test]
async fn an_async_drop_closes_the_childs_untaken_stdout() {
use std::os::fd::AsRawFd as _;
if !alone(fixture_path!(an_async_drop_closes_the_childs_untaken_stdout)) {
return;
}
let mut cmd = crate::test_child::tokio_command(Console::Hidden);
cmd.args(crate::test_child::BLOCKER_ARGV.iter().copied());
cmd.stdin(crate::Stdio::pipe()).expect("set stdin pipe");
cmd.stdout(crate::Stdio::pipe()).expect("set stdout pipe");
let mut child = cmd.spawn().expect("spawn");
let teardown = release_between_kill_and_wait(child.stdin().expect("piped stdin"));
let Some(crate::pipe::ParentEnd::Reader(stdout)) = child.os.pipes.get(&crate::stdio::Fd::STDOUT) else {
panic!("piped stdout");
};
let stdout = stdout.as_raw_fd();
assert_ne!(
unsafe { libc::fcntl(stdout, libc::F_GETFD) },
-1,
"open while the child lives"
);
drop(child);
let after = unsafe { libc::fcntl(stdout, libc::F_GETFD) };
assert_eq!(after, -1, "the drop must close the child's untaken stdout");
teardown.assert_killed();
}
#[skuld::test]
async fn a_kill_on_drop_drop_of_a_live_blocker_returns() {
let (child, teardown) = released_blocker();
drop(child);
teardown.assert_killed();
}
#[cfg(unix)]
fn in_its_own_group(mut child: Child) -> Child {
child.os.attached = crate::containment::Attached::ProcessGroup(child.pid() as i32);
child
}
#[cfg(unix)]
#[skuld::test]
async fn a_drop_of_a_live_group_root_kills_its_group() {
crate::tokio::test_runtime::assert_current_thread();
let (child, teardown) = released_blocker();
let child = in_its_own_group(child);
let pgid = child.pid() as i32;
let killed = crate::containment::unix::fault::record_kill_group();
drop(child);
assert_eq!(killed.killed(), [pgid]);
teardown.assert_killed();
}
#[skuld::test]
async fn a_drop_releases_its_resources_once_on_the_dropping_thread() {
let releases = fault::count_releases();
let backend_drops = fault::count_backend_drops();
let (child, teardown) = released_blocker();
assert_eq!(releases.get(), 0, "nothing is released before the drop");
assert_eq!(backend_drops.get(), 0, "nothing is dropped before the drop");
drop(child);
assert_eq!(releases.get(), 1, "the dropping thread releases exactly once");
assert_eq!(
backend_drops.get(),
1,
"the drop hands the backend, and tokio's Child with it, its own drop, on this thread"
);
teardown.assert_killed();
}
#[cfg(target_os = "linux")]
async fn ignoring_blocker() -> (Child, crate::tokio::ChildStdin, crate::tokio::ChildStdout) {
use ::tokio::io::AsyncReadExt as _;
let mut cmd = crate::test_child::tokio_command(Console::Hidden);
cmd.args([
"sh",
"-c",
"trap '' $(seq 1 8) $(seq 10 18) $(seq 20 64); echo r; exec cat >/dev/null",
]);
cmd.stdin(crate::Stdio::pipe()).expect("set stdin pipe");
cmd.stdout(crate::Stdio::pipe()).expect("set stdout pipe");
let mut child = cmd.spawn().expect("spawn");
let stdin = child.stdin().expect("piped stdin");
let mut stdout = child.stdout().expect("piped stdout");
let mut ready = [0u8; 2];
stdout.read_exact(&mut ready).await.expect("the root's `r` handshake");
assert_eq!(&ready, b"r\n");
(child, stdin, stdout)
}
#[cfg(target_os = "linux")]
#[skuld::test]
async fn a_kill_on_drop_drop_kills_the_root() {
let (child, stdin, _stdout) = ignoring_blocker().await;
let teardown = release_between_kill_and_wait(stdin);
drop(child);
teardown.assert_killed();
}
#[cfg(target_os = "linux")]
#[skuld::test]
async fn a_drop_kills_a_session_root_and_the_members_of_its_group() {
crate::tokio::test_runtime::assert_current_thread();
let (child, member, release) = super::group_exact_tests::releasable_root_with_a_member();
assert_eq!(child.containment(), crate::Containment::Session);
let teardown = release_between_kill_and_wait(release);
drop(child);
teardown.assert_killed();
member.assert_killed();
}
#[cfg(target_os = "linux")]
#[skuld::test]
async fn a_drop_kills_a_cgroup_root_and_its_members_and_removes_the_leaf(#[fixture(cgroup)] _group: &Group) {
use crate::test_groups::cgroup_leaf::LeafGuard;
crate::tokio::test_runtime::assert_current_thread();
let (child, member, release) = crate::test_child::member::releasable_root_with_a_member_contained(|cmd| {
cmd.contain_with(crate::ContainMode::Strongest);
});
assert_eq!(child.containment(), crate::Containment::CgroupV2);
let leaf = child.leaf_path_for_test().expect("a cgroup child holds its leaf");
let _leaf_cleanup = LeafGuard::new(leaf.clone());
let teardown = release_between_kill_and_wait(release);
let _drain = member.release_when_the_drain_blocks();
drop(child);
teardown.assert_killed();
member.assert_killed();
assert_leaf_removed(&leaf);
}
#[cfg(target_os = "macos")]
#[skuld::test]
async fn a_drop_kills_an_fd_marker_root_and_the_members_of_its_tree() {
crate::tokio::test_runtime::assert_current_thread();
let (child, member, release) = crate::test_child::member::releasable_root_with_a_member_contained(|cmd| {
cmd.contain();
});
assert_eq!(child.containment(), crate::Containment::FdMarker);
let teardown = release_between_kill_and_wait(release);
drop(child);
teardown.assert_killed();
member.assert_killed();
}
#[cfg(target_os = "linux")]
fn assert_leaf_removed(leaf: &std::path::Path) {
assert!(
!leaf.exists(),
"the drop must drain and remove the leaf: {}",
leaf.display()
);
}
#[cfg(target_os = "linux")]
#[skuld::test]
async fn an_async_drops_signals_and_bounded_release_run_inside_a_bounded_section() {
use std::cell::Cell;
use std::rc::Rc;
use crate::containment::cgroup::fault as leaf_fault;
crate::tokio::test_runtime::assert_current_thread();
crate::log_capture::install();
let in_section_at = |name: &str, detach: bool| {
let fake = crate::containment::cgroup::test_support::FakeLeaf::new(name, false);
let at_kill = Rc::new(Cell::new(None));
let at_rmdir = Rc::new(Cell::new(None));
let (kill, rmdir) = (Rc::clone(&at_kill), Rc::clone(&at_rmdir));
let _kill = leaf_fault::set_before_kill_write(move || kill.set(Some(crate::bounded::in_section())));
let (path, events) = (fake.leaf.clone(), fake.events.clone());
leaf_fault::set_rmdir_hook(move |_| {
rmdir.set(Some(crate::bounded::in_section()));
crate::containment::cgroup::test_support::FakeLeaf::rmdir(&path, &events)
});
let leaf = crate::containment::cgroup::test_support::entered_leaf_at(fake.leaf.clone());
let (child, stdin) = blocker();
let (teardown, _stdin) = if detach {
(None, Some(stdin))
} else {
(Some(release_between_kill_and_wait(stdin)), None)
};
let mut child = linux::contained_by(child, leaf);
if detach {
child.detach().expect("detach");
}
drop(child);
leaf_fault::take_rmdir_hook();
if let Some(teardown) = teardown {
teardown.assert_killed();
}
(at_kill.get(), at_rmdir.get())
};
assert_eq!(
in_section_at("cosca-async-drop-armed-section", false),
(Some(true), Some(false)),
"(the armed drop's tree kill, its leaf's rmdir)"
);
assert_eq!(
in_section_at("cosca-async-drop-detached-section", true),
(None, Some(true)),
"(no kill, the disarmed release's rmdir)"
);
assert!(!crate::bounded::in_section(), "the drop leaves the section");
}
#[cfg(target_os = "linux")]
#[skuld::test]
async fn an_async_drop_removes_an_already_drained_leaf() {
let name = "cosca-async-drop-drained";
let (fake, leaf) = linux::fake_leaf(name, false);
let (child, teardown) = released_blocker();
let (steps, levels) = linux::dropped(linux::contained_by(child, leaf), name);
assert_eq!(steps, ["kill", "rmdir populated 0"]);
assert_eq!(
fake.kill_written(),
crate::containment::cgroup::KILL_PAYLOAD,
"the tree kill must write cgroup.kill"
);
assert!(!fake.leaf.exists(), "a drained leaf is removed");
assert_eq!(levels, Vec::<log::Level>::new());
teardown.assert_killed();
}
#[cfg(target_os = "linux")]
#[skuld::test]
async fn a_kill_on_drop_false_drop_of_an_armed_leaf_never_blocks() {
if !alone(fixture_path!(a_kill_on_drop_false_drop_of_an_armed_leaf_never_blocks)) {
return;
}
let name = "cosca-async-drop-opted-out-armed";
let (fake, leaf) = linux::fake_leaf(name, true);
let mut cmd = crate::test_child::command(Console::Hidden);
cmd.args(crate::test_child::BLOCKER_ARGV.iter().copied());
cmd.stdin(crate::Stdio::pipe()).expect("set stdin pipe");
cmd.kill_on_drop(false);
let mut child = crate::tokio::spawn::spawn_uncommitted(&mut cmd).expect("spawn");
let stdin = child.stdin().expect("piped stdin");
let child = linux::contained_by(child, leaf);
assert!(!child.kill_on_drop, "the command opted out");
let root = linux::Pidfd::of(&child);
let view = child.read_root_view(crate::containment::dispatch::TeardownCaller::Drop);
let killed = child.kill_tree_members_unless_reaped(&view);
assert!(killed.completed(), "kill the tree: {killed:?}");
assert_eq!(
fake.kill_written(),
crate::containment::cgroup::KILL_PAYLOAD,
"this handle's tree kill must write cgroup.kill"
);
child.settle_tree(killed, false).expect("the tree kill left nothing");
assert!(child.tree_killed(), "this handle killed the tree");
fake.clear_kill();
let (steps, levels) = linux::dropped(child, name);
assert_eq!(steps, ["rmdir populated 1"]);
assert_eq!(fake.kill_written(), b"", "the landed kill is not written again");
assert!(fake.leaf.exists());
assert_eq!(levels, [log::Level::Warn]);
assert_eq!(
root.ended_after_closing(stdin),
linux::Ended::Exited(0),
"an opted-out drop must not signal the root"
);
}
#[cfg(target_os = "linux")]
#[skuld::test]
async fn a_teardown_that_ran_no_tree_kill_does_not_mark_the_tree_killed() {
let name = "cosca-async-teardown-no-kill";
let (_fake, leaf) = linux::fake_leaf(name, true);
let (child, stdin) = blocker();
let mut child = linux::contained_by(child, leaf);
child.detach().expect("detach");
child.tear_down_now(crate::containment::dispatch::TeardownCaller::Drop);
crate::containment::cgroup::fault::take_rmdir_hook();
assert!(!child.tree_killed(), "no tree kill ran, so none is marked");
drop(stdin);
}
#[cfg(target_os = "linux")]
#[skuld::test]
async fn a_disarmed_never_killed_drop_never_kills_and_logs_at_debug() {
if !alone(fixture_path!(
a_disarmed_never_killed_drop_never_kills_and_logs_at_debug
)) {
return;
}
let name = "cosca-async-drop-disarmed-never-killed";
let (fake, leaf) = linux::fake_leaf(name, true);
let (child, stdin) = blocker();
let mut child = linux::contained_by(child, leaf);
child.detach().expect("detach");
let root = linux::Pidfd::of(&child);
let (steps, levels) = linux::dropped(child, name);
assert_eq!(steps, ["rmdir populated 1"]);
assert_eq!(linux::kill_file(&fake), b"", "nothing may write cgroup.kill");
assert!(fake.leaf.exists());
assert_eq!(levels, [log::Level::Debug]);
assert_eq!(root.ended_after_closing(stdin), linux::Ended::Exited(0));
}
#[cfg(target_os = "linux")]
#[skuld::test]
async fn a_root_whose_kill_fails_is_handed_off_not_waited_on() {
crate::tokio::test_runtime::assert_current_thread();
if !alone(fixture_path!(a_root_whose_kill_fails_is_handed_off_not_waited_on)) {
return;
}
let name = "cosca-async-drop-handoff";
let (fake, leaf) = linux::fake_leaf(name, false);
let (child, stdin) = blocker();
let mut child = linux::contained_by(child, leaf);
let root = linux::Pidfd::of(&child);
let pid = child.pid();
let armed = fault::force_kill_failure();
child.kill_tree().expect_err("the forced backstop failure surfaces");
drop(armed);
fake.clear_kill();
let _armed = fault::force_kill_failure();
let backend_drops = fault::count_backend_drops();
let mark = crate::log_capture::mark();
let (steps, levels) = linux::dropped(child, name);
assert_eq!(
steps,
["kill", "rmdir populated 0"],
"tree kill, then a release that removes"
);
assert_eq!(
fake.kill_written(),
crate::containment::cgroup::KILL_PAYLOAD,
"the drop's tree kill must write cgroup.kill, not only record the step"
);
assert_eq!(levels, Vec::<log::Level>::new(), "the drained leaf is not warned about");
let needle = format!("async child {pid} could not be terminated on drop");
assert_eq!(
crate::log_capture::levels_since(mark, &needle),
[log::Level::Warn],
"the root the drop could not signal is logged once"
);
assert_eq!(
backend_drops.get(),
1,
"the drop must hand tokio its own Child to drop, never forget it"
);
assert!(!fake.leaf.exists(), "the drained leaf is released");
assert_eq!(
root.ended_after_closing(stdin),
linux::Ended::Exited(0),
"neither the tree kill nor the drop may have signalled the root"
);
}
#[skuld::test]
async fn unreaped_root_could_not_be_terminated_on_drop_is_logged() {
crate::tokio::test_runtime::assert_current_thread();
crate::log_capture::install();
let (child, stdin) = blocker();
let pid = child.pid();
let _armed = fault::force_kill_failure();
let mark = crate::log_capture::mark();
drop(child);
let needle = format!("async child {pid} could not be terminated on drop");
assert_eq!(crate::log_capture::levels_since(mark, &needle), [log::Level::Warn]);
drop(stdin);
}
#[cfg(target_os = "linux")]
#[skuld::test]
async fn drop_warns_instead_of_asserting_on_a_real_teardown_mechanism_failure() {
crate::tokio::test_runtime::assert_current_thread();
crate::log_capture::install();
let dir = tempfile::tempdir().expect("tempdir");
let leaf_path = dir.path().join("cosca-async-drop-kill-fail-leaf");
std::fs::create_dir(&leaf_path).expect("create the leaf");
std::fs::write(leaf_path.join("occupant"), "").expect("keep the leaf unremovable");
std::fs::create_dir(leaf_path.join("cgroup.kill")).expect("make cgroup.kill a directory");
crate::child::spawn::fault::set_attachment_override(crate::containment::Attachment {
containment: crate::containment::Containment::CgroupV2,
attached: crate::containment::Attached::Cgroup(crate::containment::cgroup::test_support::entered_leaf_at(
leaf_path.clone(),
)),
graceful: crate::graceful::GracefulMechanism::Process,
});
let mut cmd = crate::test_child::tokio_command(Console::Hidden);
cmd.args(crate::test_child::BLOCKER_ARGV.iter().copied());
cmd.stdin(crate::Stdio::pipe()).expect("set stdin pipe");
cmd.stdout(crate::Stdio::null()).expect("set stdout");
let mut child = cmd.spawn().expect("spawn");
let teardown = release_between_kill_and_wait(child.stdin().expect("piped stdin"));
let pid = child.pid();
let sends = crate::send_log::Capture::start();
let forced = child
.kill_tree()
.expect_err("the forced cgroup.kill failure must surface from kill_tree");
assert!(
matches!(&forced, crate::error::Error::Io(io) if io.raw_os_error() == Some(libc::EISDIR)),
"the forced failure must be a mechanism-class Error::Io(EISDIR), got {forced:?}"
);
let mark = crate::log_capture::mark();
let marker = "Child::drop: contained-tree teardown did not fully succeed";
std::thread::spawn(move || log::warn!("{marker}: from another thread"))
.join()
.expect("emit from another thread");
let unwound = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| drop(child)));
assert!(
unwound.is_ok(),
"Child::drop must not panic on a real teardown-mechanism failure: {unwound:?}"
);
let records = crate::log_capture::records_since_on_current_thread(mark, marker);
assert_eq!(
records.iter().map(|(level, _)| *level).collect::<Vec<_>>(),
[log::Level::Warn],
"a real teardown-mechanism failure during Drop must be logged at warn, got {records:?}"
);
teardown.assert_killed();
assert!(
sends.sent(pid, crate::signal::Sig::Kill),
"the drop must send the root SIGKILL: {:?}",
sends.entries()
);
}
#[skuld::test]
async fn a_teardown_of_a_reaped_child_is_reaped_armed_or_not() {
crate::tokio::test_runtime::assert_current_thread();
for kill_on_drop in [true, false] {
let mut cmd = crate::test_child::tokio_command(Console::Hidden);
cmd.args(crate::test_child::BLOCKER_ARGV.iter().copied());
cmd.stdin(crate::Stdio::pipe()).expect("set stdin pipe");
cmd.stdout(crate::Stdio::null()).expect("set stdout");
cmd.kill_on_drop(kill_on_drop);
let mut child = cmd.spawn().expect("spawn");
drop(child.stdin().expect("piped stdin"));
child.wait().await.expect("the child exits once its stdin closes");
assert_eq!(
child.tear_down_now(crate::containment::dispatch::TeardownCaller::Drop),
crate::error::ChildFate::Reaped,
"kill_on_drop={kill_on_drop}"
);
}
}