use super::{ProcSource, Waited};
#[cfg(target_os = "macos")]
use crate::test_groups::{tracer_group, Group};
pub(in crate::tokio::child) fn proc_source(child: ::tokio::process::Child) -> ProcSource {
#[cfg(target_os = "linux")]
{
use rustix::process::{pidfd_open, Pid, PidfdFlags};
let pid = child.id().expect("tokio owns an un-reaped child");
let pidfd = pidfd_open(Pid::from_raw(pid as i32).expect("pid"), PidfdFlags::empty()).expect("pidfd_open");
ProcSource::new(child, pidfd)
}
#[cfg(target_os = "macos")]
{
let pid = child.id().expect("tokio owns an un-reaped child");
ProcSource::new(
child,
crate::signal::read_identity(pid).expect("the identity is readable"),
)
}
#[cfg(windows)]
ProcSource::new(child)
}
#[cfg(unix)]
pub(in crate::tokio::child) fn wait_exited_unreaped(pid: u32) {
let mut info: libc::siginfo_t = unsafe { std::mem::zeroed() };
let rc = unsafe { libc::waitid(libc::P_PID, pid as libc::id_t, &mut info, libc::WEXITED | libc::WNOWAIT) };
assert_eq!(rc, 0, "waitid: {}", std::io::Error::last_os_error());
}
#[cfg(unix)]
pub(in crate::tokio::child) fn reap_behind_the_owner(pid: u32) {
let mut info: libc::siginfo_t = unsafe { std::mem::zeroed() };
let rc = unsafe { libc::waitid(libc::P_PID, pid as libc::id_t, &mut info, libc::WEXITED) };
assert_eq!(rc, 0, "waitid: {}", std::io::Error::last_os_error());
}
#[skuld::test]
async fn wait_and_reap_waits_for_the_childs_own_exit_and_never_kills() {
use std::io::{Read, Write};
let (listener, addr) = crate::test_child::registration_rendezvous();
let child = {
crate::test_spawn::spawn_tokio(
::tokio::process::Command::from(crate::test_reexec::command(
std::env::current_exe().expect("current_exe"),
))
.args(crate::test_reexec::fixture_args(
crate::test_child::FIXTURE_REGISTERS_THEN_BLOCKS_TEST,
))
.env(crate::test_child::FIXTURE_REGISTERS_THEN_BLOCKS_ADDR_ENV, &addr)
.env(crate::test_child::ack::ACK_ENV, "1")
.stdout(std::process::Stdio::null())
.stderr(std::process::Stdio::null()),
)
.expect("spawn the rendezvous fixture")
};
let pid = child.id().expect("tokio owns an un-reaped child");
let mut proc = proc_source(child);
let target = crate::Process::from_pid(pid)
.found()
.expect("resolve the freshly spawned fixture's pid")
.id();
let mut sock = crate::test_child::accept_or_die(&listener, target);
let mut tag = [0u8; 1];
sock.read_exact(&mut tag).expect("read the fixture's readiness tag");
sock.write_all(b"g").expect("release the fixture");
sock.flush().expect("flush the release byte");
assert_eq!(proc.wait_and_reap(pid), Waited::Exited);
let status = proc
.try_wait()
.expect("try_wait")
.expect("wait_and_reap must return only after the child has exited");
assert_eq!(
status.code(),
Some(0),
"the fixture must have exited on its own; a kill inside wait_and_reap would report the \
forced code instead ({status:?})"
);
}
fn spawn_a_tokio_child_that_exits() -> ::tokio::process::Child {
crate::test_spawn::spawn_tokio(
::tokio::process::Command::from(crate::test_reexec::command(
std::env::current_exe().expect("current_exe"),
))
.args(["--exact", "__cosca_no_such_test__"])
.stdout(std::process::Stdio::null())
.stderr(std::process::Stdio::null()),
)
.expect("spawn")
}
#[cfg_attr(
debug_assertions,
should_panic(expected = "already-reaped child where one was impossible")
)]
#[skuld::test]
async fn wait_and_reap_refuses_an_already_reaped_child_the_caller_never_awaited() {
let child = spawn_a_tokio_child_that_exits();
let pid = child.id().expect("tokio owns an un-reaped child");
let mut proc = proc_source(child);
proc.wait().await.expect("wait");
proc.wait_and_reap(pid);
assert!(proc.is_reaped(), "the child was reaped by the wait() above");
}
#[cfg(unix)]
#[cfg_attr(
debug_assertions,
should_panic(expected = "already-reaped child where one was impossible")
)]
#[skuld::test]
async fn the_elevated_cleanup_entry_refuses_an_already_reaped_child() {
let mut cmd = crate::tokio::Command::new();
cmd.executable(std::env::current_exe().expect("current_exe"))
.args(["cosca_unit_tests", "--exact", "__cosca_no_such_test__"]);
crate::test_reexec::scrub_env(|var| _ = cmd.env_remove(var));
cmd.stdout(crate::stdio::Stdio::null()).expect("stdout null");
cmd.stderr(crate::stdio::Stdio::null()).expect("stderr null");
let mut child = cmd.spawn().expect("spawn");
child.wait().await.expect("wait");
child.wait_and_reap_blocking();
assert!(
matches!(child.try_wait(), Ok(Some(_))),
"the child was reaped by the wait() above"
);
}
#[cfg(target_os = "macos")]
#[skuld::test]
async fn wait_and_reap_on_a_pid_that_is_not_our_child_is_foreign_and_records_no_reap() {
crate::tokio::test_runtime::assert_current_thread();
let reaps = crate::child::spawn::fault::record_teardown_reaps();
let child = spawn_a_tokio_child_that_exits();
let real_pid = child.id().expect("tokio owns an un-reaped child");
let mut proc = proc_source(child);
let not_our_child = i32::MAX as u32;
assert_eq!(proc.wait_and_reap(not_our_child), Waited::Foreign);
assert_eq!(reaps.recorded(), vec![], "a refused wait must record no reap");
proc.forget_foreign();
reap_behind_the_owner(real_pid);
}
#[cfg(unix)]
#[skuld::test]
async fn wait_and_reap_of_a_child_reaped_behind_the_owner_is_foreign() {
crate::tokio::test_runtime::assert_current_thread();
let reaps = crate::child::spawn::fault::record_teardown_reaps();
let child = spawn_a_tokio_child_that_exits();
let pid = child.id().expect("tokio owns an un-reaped child");
let mut proc = proc_source(child);
reap_behind_the_owner(pid);
assert_eq!(proc.wait_and_reap(pid), Waited::Foreign);
assert_eq!(reaps.recorded(), vec![], "no exit was observed, so no reap is recorded");
proc.forget_foreign();
}
#[cfg(unix)]
#[skuld::test]
async fn reap_now_of_a_child_reaped_behind_the_owner_is_gone() {
crate::tokio::test_runtime::assert_current_thread();
let reaps = crate::child::spawn::fault::record_teardown_reaps();
let child = spawn_a_tokio_child_that_exits();
let pid = child.id().expect("tokio owns an un-reaped child");
let proc = proc_source(child);
reap_behind_the_owner(pid);
let fate = proc.reap_now(pid, None);
assert_eq!(fate, crate::error::ChildFate::Gone);
assert_eq!(reaps.recorded(), vec![], "no exit was observed, so no reap is recorded");
}
#[cfg(unix)]
#[skuld::test]
async fn tokio_forget_foreign_warns_naming_the_leak() {
crate::tokio::test_runtime::assert_current_thread();
crate::log_capture::install();
let mark = crate::log_capture::mark();
let child = spawn_a_tokio_child_that_exits();
let pid = child.id().expect("tokio owns an un-reaped child");
let mut proc = proc_source(child);
reap_behind_the_owner(pid);
assert_eq!(proc.wait_and_reap(pid), Waited::Foreign);
proc.forget_foreign();
let warns: Vec<_> = crate::log_capture::records_since_on_current_thread(mark, &format!("child {pid}"))
.into_iter()
.filter(|(level, _)| *level == log::Level::Warn)
.collect();
assert_eq!(warns.len(), 1, "exactly one warning: {warns:?}");
assert!(warns[0].1.contains("leak"), "the warning must name the leak: {warns:?}");
assert!(proc.is_reaped(), "a forgotten child has nothing left to reap");
}
#[cfg(unix)]
#[skuld::test]
async fn a_forgotten_child_answers_echild_to_wait_and_try_wait() {
let child = spawn_a_tokio_child_that_exits();
let pid = child.id().expect("tokio owns an un-reaped child");
let mut proc = proc_source(child);
reap_behind_the_owner(pid);
proc.forget_foreign();
for waited in [proc.try_wait().map(drop), proc.wait().await.map(drop)] {
match waited {
Err(crate::error::Error::Io(e)) => assert_eq!(e.raw_os_error(), Some(libc::ECHILD), "{e}"),
other => panic!("a forgotten child must answer ECHILD, got {other:?}"),
}
}
}
#[cfg(unix)]
#[skuld::test]
async fn tokio_forget_foreign_keeps_the_untaken_stdout() {
use ::tokio::io::AsyncReadExt as _;
let child = crate::test_spawn::spawn_tokio(
::tokio::process::Command::new("sh")
.args(["-c", "echo hello"])
.stdout(std::process::Stdio::piped()),
)
.expect("spawn");
let pid = child.id().expect("tokio owns an un-reaped child");
let mut proc = proc_source(child);
reap_behind_the_owner(pid);
assert_eq!(proc.wait_and_reap(pid), Waited::Foreign);
proc.forget_foreign();
let mut stdout = proc.take_stdout().expect("the untaken stdout survives the forget");
let mut line = String::new();
stdout.read_to_string(&mut line).await.expect("read");
assert_eq!(line, "hello\n");
}
#[cfg(unix)]
#[skuld::test]
async fn dropping_a_backend_implicitly_releases_a_child_shown_ours() {
let child = spawn_a_tokio_child_that_exits();
let pid = child.id().expect("tokio owns an un-reaped child");
let proc = proc_source(child);
wait_exited_unreaped(pid);
let backend_drops = super::fault::count_backend_drops();
drop(proc);
assert_eq!(backend_drops.get(), 1, "a child shown ours is released to tokio's drop");
}
#[cfg(unix)]
#[skuld::test]
async fn dropping_a_backend_implicitly_forgets_a_child_whose_peek_failed() {
use crate::wait::exit_only::seams::force_peek_once;
let child = spawn_a_tokio_child_that_exits();
let pid = child.id().expect("tokio owns an un-reaped child");
let proc = proc_source(child);
wait_exited_unreaped(pid);
let backend_drops = super::fault::count_backend_drops();
let _failed = force_peek_once(Err(std::io::Error::other("forced peek failure 5b1d")));
drop(proc);
assert_eq!(backend_drops.get(), 0, "tokio's Child must have been forgotten");
reap_behind_the_owner(pid); }
#[cfg(unix)]
#[skuld::test]
async fn dropping_a_backend_implicitly_forgets_a_child_reaped_elsewhere() {
let child = spawn_a_tokio_child_that_exits();
let pid = child.id().expect("tokio owns an un-reaped child");
let proc = proc_source(child);
reap_behind_the_owner(pid);
let backend_drops = super::fault::count_backend_drops();
drop(proc);
assert_eq!(backend_drops.get(), 0, "tokio's Child must have been forgotten");
}
#[cfg(unix)]
#[skuld::test]
async fn wait_closes_the_untaken_stdin_first() {
use std::future::Future;
use std::os::fd::AsFd;
let child = crate::test_spawn::spawn_tokio(
::tokio::process::Command::new("cat")
.stdin(std::process::Stdio::piped())
.stdout(std::process::Stdio::null())
.stderr(std::process::Stdio::null()),
)
.expect("spawn");
let pid = child.id().expect("tokio owns an un-reaped child");
let held_writer = child
.stdin
.as_ref()
.expect("piped stdin")
.as_fd()
.try_clone_to_owned()
.expect("duplicate the stdin write end");
let mut proc = proc_source(child);
{
let mut waiting = Box::pin(proc.wait());
std::future::poll_fn(|cx| {
drop(waiting.as_mut().poll(cx));
std::task::Poll::Ready(())
})
.await;
}
let ProcSource::Tokio { stdin, .. } = &proc else {
panic!("a tokio backend");
};
let closed = stdin.is_none();
assert!(!proc.is_reaped(), "the one poll finished the wait");
proc.reap_now(pid, None); drop(held_writer);
assert!(closed, "wait must close stdin before it waits");
}
#[cfg(unix)]
#[skuld::test]
async fn dropping_a_backend_implicitly_after_wait_releases_it() {
let child = spawn_a_tokio_child_that_exits();
let mut proc = proc_source(child);
proc.wait().await.expect("wait");
assert!(proc.is_reaped());
let backend_drops = super::fault::count_backend_drops();
drop(proc);
assert_eq!(backend_drops.get(), 1, "a reaped child's backend is released");
}
#[cfg(unix)]
#[skuld::test]
async fn an_implicit_drop_logs_its_forget_only_when_not_unwinding() {
crate::tokio::test_runtime::assert_current_thread();
crate::log_capture::install();
let reaped_elsewhere = || {
let child = spawn_a_tokio_child_that_exits();
let pid = child.id().expect("tokio owns an un-reaped child");
let proc = proc_source(child);
reap_behind_the_owner(pid);
proc
};
let marker = "dropped without a release";
let mark = crate::log_capture::mark();
drop(reaped_elsewhere());
assert!(
crate::log_capture::contains_since(mark, marker),
"a plain drop logs the forget"
);
let proc = reaped_elsewhere();
let mark = crate::log_capture::mark();
let unwound = std::panic::catch_unwind(std::panic::AssertUnwindSafe(move || {
let _held = proc;
panic!("unwind with the backend held");
}));
assert!(unwound.is_err());
assert!(
!crate::log_capture::contains_since(mark, marker),
"no log may run while the thread unwinds"
);
}
#[cfg(unix)]
#[skuld::test]
async fn forget_if_foreign_leaves_a_child_nothing_has_reaped() {
let child = spawn_a_tokio_child_that_exits();
let pid = child.id().expect("tokio owns an un-reaped child");
let mut proc = proc_source(child);
wait_exited_unreaped(pid);
proc.forget_if_foreign();
assert!(!proc.is_reaped(), "an unreaped zombie is still tokio's to reap");
proc.wait().await.expect("tokio reaps it");
}
#[cfg(unix)]
#[skuld::test]
async fn wait_and_reap_blocking_forgets_a_foreign_reaped_child() {
let mut child = spawn_cosca_child_that_exits();
reap_behind_the_owner(child.id().pid());
let fate = child.wait_and_reap_blocking();
assert!(child.proc_mut().is_reaped(), "a foreign-reaped child must be forgotten");
assert_eq!(
fate,
crate::error::ChildFate::Killed,
"the caller's kill was delivered; the exit was collected by someone else"
);
}
#[cfg(unix)]
#[skuld::test]
async fn kill_of_a_foreign_reaped_child_forgets_it() {
let mut child = spawn_cosca_child_that_exits();
reap_behind_the_owner(child.id().pid());
child.kill().expect("a kill of a foreign-reaped child answers Ok");
assert!(child.proc_mut().is_reaped(), "a foreign-reaped child must be forgotten");
}
#[cfg(unix)]
fn spawn_cosca_child_that_exits() -> crate::tokio::Child {
spawn_cosca_child_that_exits_result().expect("spawn")
}
#[cfg(unix)]
fn spawn_cosca_child_that_exits_result() -> Result<crate::tokio::Child, crate::error::Error> {
let mut cmd = crate::tokio::Command::new();
cmd.executable(std::env::current_exe().expect("current_exe"))
.args(["cosca_unit_tests", "--exact", "__cosca_no_such_test__"]);
crate::test_reexec::scrub_env(|var| _ = cmd.env_remove(var));
cmd.stdout(crate::stdio::Stdio::null()).expect("stdout null");
cmd.stderr(crate::stdio::Stdio::null()).expect("stderr null");
cmd.spawn()
}
#[cfg(unix)]
fn waitid_status(pid: u32) -> std::process::ExitStatus {
let mut info: libc::siginfo_t = unsafe { std::mem::zeroed() };
let rc = unsafe { libc::waitid(libc::P_PID, pid as libc::id_t, &mut info, libc::WEXITED | libc::WNOWAIT) };
assert_eq!(rc, 0, "waitid: {}", std::io::Error::last_os_error());
super::exit_status_of(&info)
}
#[cfg(unix)]
#[skuld::test]
fn exit_status_of_matches_std_for_exited_and_killed_children() {
for script in ["exit 3", "kill -KILL $$"] {
let mut child = crate::test_spawn::spawn(std::process::Command::new("sh").args(["-c", script])).expect("spawn");
let decoded = waitid_status(child.id());
let real = child.wait().expect("wait");
assert_eq!(decoded, real, "`sh -c '{script}'`");
}
}
#[cfg(unix)]
#[skuld::test]
fn exit_status_from_parts_encodes_a_dumped_child() {
use std::os::unix::process::ExitStatusExt as _;
let dumped = super::exit_status_from_parts(libc::CLD_DUMPED, libc::SIGSEGV);
assert_eq!(dumped.signal(), Some(libc::SIGSEGV));
assert!(dumped.core_dumped(), "{dumped:?}");
let killed = super::exit_status_from_parts(libc::CLD_KILLED, libc::SIGKILL);
assert_eq!(killed.signal(), Some(libc::SIGKILL));
assert!(!killed.core_dumped(), "{killed:?}");
assert_eq!(super::exit_status_from_parts(libc::CLD_EXITED, 3).code(), Some(3));
}
#[cfg(target_os = "macos")]
fn exited_unreaped_with(identity: impl FnOnce(u64) -> Option<u64>) -> (ProcSource, u32) {
let child = spawn_a_tokio_child_that_exits();
let pid = child.id().expect("tokio owns an un-reaped child");
wait_exited_unreaped(pid);
let real = crate::signal::read_identity(pid)
.expect("readable")
.expect("a zombie still has a unique id");
(ProcSource::new(child, identity(real)), pid)
}
#[cfg(target_os = "macos")]
#[skuld::test]
async fn macos_wait_and_reap_on_a_pid_with_another_unique_id_is_foreign() {
let (mut proc, pid) = exited_unreaped_with(|real| Some(real ^ 1));
assert_eq!(proc.wait_and_reap(pid), Waited::Foreign);
proc.forget_foreign();
reap_behind_the_owner(pid); }
#[cfg(target_os = "macos")]
#[skuld::test]
async fn macos_forget_if_foreign_on_a_pid_with_another_unique_id_forgets() {
let (mut proc, pid) = exited_unreaped_with(|real| Some(real ^ 1));
proc.forget_if_foreign();
assert!(proc.is_reaped(), "a pid with another unique id is not the child");
reap_behind_the_owner(pid);
}
#[cfg(target_os = "macos")]
#[skuld::test]
async fn macos_forget_if_foreign_on_a_failed_peek_forgets() {
use crate::wait::exit_only::seams::force_peek_once;
let (mut proc, pid) = exited_unreaped_with(Some);
let _failed = force_peek_once(Err(std::io::Error::other("forced peek failure")));
proc.forget_if_foreign();
assert!(proc.is_reaped(), "a child that cannot be verified is forgotten");
reap_behind_the_owner(pid);
}
#[cfg(target_os = "macos")]
#[skuld::test]
async fn macos_wait_and_reap_with_no_unique_id_is_unverified() {
let (mut proc, pid) = exited_unreaped_with(|_| None);
assert_eq!(proc.wait_and_reap(pid), Waited::Unverified);
proc.forget_foreign();
reap_behind_the_owner(pid);
}
#[cfg(target_os = "macos")]
#[skuld::test]
async fn macos_reap_now_with_no_unique_id_leaves_the_child_running() {
let (proc, pid) = exited_unreaped_with(|_| None);
let id = crate::identity::ProcessId::current();
let fate = proc.reap_now(pid, Some(id));
assert_eq!(fate, crate::error::ChildFate::Running { id: Some(id) });
reap_behind_the_owner(pid);
}
#[cfg(target_os = "macos")]
#[skuld::test]
async fn macos_reap_now_with_another_unique_id_is_gone() {
let (proc, pid) = exited_unreaped_with(|real| Some(real ^ 1));
let fate = proc.reap_now(pid, None);
assert_eq!(fate, crate::error::ChildFate::Gone);
reap_behind_the_owner(pid);
}
#[cfg(target_os = "macos")]
#[skuld::test]
async fn macos_reap_now_of_a_zombie_launchd_holds_is_killed() {
use crate::wait::exit_only::seams::force_peek_once;
use crate::wait::exit_only::{Foreign, Peek};
let (proc, pid) = exited_unreaped_with(Some);
let _orphaned = force_peek_once(Ok(Peek::Foreign(Foreign::Orphaned)));
let fate = proc.reap_now(pid, None);
assert_eq!(fate, crate::error::ChildFate::Killed);
reap_behind_the_owner(pid);
}
#[cfg(target_os = "macos")]
#[skuld::test]
async fn macos_forget_if_foreign_with_no_unique_id_forgets() {
let (mut proc, pid) = exited_unreaped_with(|_| None);
proc.forget_if_foreign();
assert!(proc.is_reaped(), "a child with no unique id is foreign");
reap_behind_the_owner(pid);
}
#[cfg(target_os = "macos")]
#[skuld::test]
async fn macos_a_refused_own_identity_read_fails_the_spawn_and_the_program_does_not_run() {
crate::tokio::test_runtime::assert_current_thread();
let _forced = crate::child::spawn::unique_report::seams::force_child_read_errno(libc::EPERM);
use crate::child::spawn::identity_macos_tests::{ran_marker, RAN_ARGV};
let (stdout, reader) = ran_marker();
let mut cmd = crate::tokio::Command::new();
cmd.args(RAN_ARGV);
cmd.stdout(stdout).expect("set stdout");
let err = cmd.spawn().err();
match crate::child::spawn::failure::expect_not_started(err.expect("a refused identity read must fail the spawn")) {
crate::error::Error::Unassessable { detail, .. } => assert!(detail.contains("did not start"), "{detail}"),
other => panic!("expected Unassessable, got {other:?}"),
}
crate::child::spawn::identity_macos_tests::assert_program_did_not_run(cmd, reader);
}
#[cfg(target_os = "macos")]
#[skuld::test]
async fn macos_wait_and_reap_on_a_failed_peek_is_unverified() {
use crate::wait::exit_only::seams::force_peek_once;
let (mut proc, pid) = exited_unreaped_with(Some);
let _failed = force_peek_once(Err(std::io::Error::other("forced peek failure")));
assert_eq!(proc.wait_and_reap(pid), Waited::Unverified);
proc.forget_foreign();
reap_behind_the_owner(pid);
}
#[cfg(target_os = "macos")]
#[skuld::test]
async fn macos_wait_and_reap_of_a_zombie_launchd_holds_is_foreign_and_warns() {
use crate::wait::exit_only::seams::force_peek_once;
use crate::wait::exit_only::{Foreign, Peek};
crate::log_capture::install();
let (mut proc, pid) = exited_unreaped_with(Some);
let mark = crate::log_capture::mark();
let _orphaned = force_peek_once(Ok(Peek::Foreign(Foreign::Orphaned)));
assert_eq!(proc.wait_and_reap(pid), Waited::Foreign);
let records = crate::log_capture::records_since_on_current_thread(mark, &format!("child {pid}"));
assert!(
records
.iter()
.any(|(level, text)| *level == log::Level::Warn && text.contains("launchd holds its zombie")),
"{records:?}"
);
proc.forget_foreign();
reap_behind_the_owner(pid);
}
#[cfg(target_os = "macos")]
#[skuld::test]
async fn macos_wait_and_reap_of_a_child_a_tracer_holds_waits_for_the_hand_back(
#[fixture(tracer_group)] _group: &Group,
) {
use crate::test_support::tracer::{self, Mode, Report, Tracee};
let (child, stdin) = tracer::spawn_tracee_tokio(Tracee::Plain).await;
let pid = child.id().expect("tokio owns an un-reaped child");
let unique = crate::signal::read_identity(pid).expect("readable");
let mut helper = tracer::start(Mode::Auto).attach_tokio(&child);
assert_eq!(helper.recv(), Report::Attached);
let mut proc = ProcSource::new(child, unique);
let waited = std::thread::scope(|s| {
let waiter = s.spawn(|| proc.wait_and_reap(pid));
drop(stdin);
assert_eq!(helper.recv(), Report::Reaped);
waiter.join().expect("the waiter")
});
assert_eq!(waited, Waited::Exited, "a held child is not foreign");
assert!(!proc.is_reaped(), "the zombie is still tokio's to reap");
drop(helper);
let status = proc.wait().await.expect("the handed-back zombie is ours to reap");
assert!(status.success(), "{status:?}");
}
#[cfg(target_os = "linux")]
#[skuld::test]
async fn reap_now_of_a_child_reaped_behind_the_owner_after_the_kill_is_killed() {
crate::tokio::test_runtime::assert_current_thread();
let child = crate::test_spawn::spawn_tokio(
::tokio::process::Command::new("sleep")
.arg("600")
.stdout(std::process::Stdio::null())
.stderr(std::process::Stdio::null()),
)
.expect("spawn");
let pid = child.id().expect("tokio owns an un-reaped child");
let proc = proc_source(child);
let _foreign_reap = crate::child::spawn::fault::set_between_kill_and_wait(move || {
crate::test_child::wait_until_zombie(pid);
reap_behind_the_owner(pid);
});
let fate = proc.reap_now(pid, None);
assert_eq!(fate, crate::error::ChildFate::Killed);
}