use std::sync::atomic::{AtomicU32, Ordering};
use std::sync::Arc;
use crate::test_child::{blocker, Console};
use std::time::{Duration, Instant};
use super::fixtures::{status, try_wait, wait_status, Blocker};
use crate::child::owned::{ChildWaitOutcome, OwnedChild};
use crate::elevation::front::TrackedKind;
use crate::error::Error;
use crate::identity::kinfo::kinfo_proc;
use crate::identity::{exit_record, short_info_held_by, FakeKernel, HostKernel, Kernel, UniqRead, LAUNCHD};
use crate::os_process::child::Foreign;
use crate::os_process::macos::child::MacosChild;
use crate::os_process::macos::kqueue::test_hooks;
use crate::os_process::macos::ExitWatch;
use crate::signal::Sig;
use crate::test_groups::{setuid, Group};
use crate::wait::exit_only::macos_tests::{assert_zombie_consumed, echild_yet_resolvable, found, unique_of};
fn far() -> Instant {
Instant::now() + Duration::from_secs(3600)
}
fn is_foreign(outcome: &Result<ChildWaitOutcome, crate::error::Error>) -> bool {
matches!(outcome, Ok(ChildWaitOutcome::Foreign(_)))
}
#[skuld::test]
fn a_drop_whose_consume_finds_none_after_the_wait_saw_the_exit_takes_the_echild_path() {
let (mut b, kernel) = Blocker::spawn_over(|pid, _| FakeKernel::over(&HostKernel).on_consume(pid, Ok(None)));
b.end_child_and_confirm_exit();
let status = wait_status(&b.owned);
assert!(status.success(), "{status:?}");
assert!(!kernel.all_rows_taken(), "the wait consumed");
let pid = b.pid;
drop(b);
assert!(kernel.all_rows_taken(), "the drop must consume");
assert!(
crate::test_child::is_unreaped_child(pid),
"the zombie was taken though the consume found nothing"
);
crate::test_child::reaped_elsewhere::reap_behind(pid);
}
#[skuld::test]
fn a_second_peek_runs_after_every_first_reap() {
let (mut b, kernel) =
Blocker::spawn_over(|pid, _| FakeKernel::over(&HostKernel).on_consume(pid, Ok(Some(exit_record(0)))));
b.end_child_and_confirm_exit();
let status = wait_status(&b.owned);
assert!(status.success(), "{status:?}");
assert!(!kernel.all_rows_taken(), "the wait consumed");
let pid = b.pid;
drop(b);
assert!(kernel.all_rows_taken(), "the first reap must consume");
assert_zombie_consumed(pid, "the second reap");
}
#[skuld::test]
fn an_owned_child_lends_the_kernel_its_box_was_built_with() {
let (b, kernel) = Blocker::spawn_over(|pid, _| FakeKernel::over(&HostKernel).on_peek(pid, Ok(None)));
assert_eq!(b.owned.kernel().peek(b.pid).expect("the stated row"), None);
assert!(kernel.all_rows_taken(), "the lent kernel answered from the row");
}
const MARKER: &str = "COSCA_TESTCFG_SHARED_SIGIGN";
const CASE_ENV: &str = "COSCA_TESTCFG_SHARED_SIGIGN_CASE";
fn run_case(path: &str, case: &str) {
crate::test_child::run_fixture_case(path, MARKER, CASE_ENV, case);
}
fn no_block_after_the_kernel_reaps(pid: u32) -> crate::wait::block_probe::Armed {
crate::wait::block_probe::on_each_block(move |block| {
if !block.is_round() || block.armed == Some(Duration::ZERO) {
return;
}
if !crate::test_child::is_unreaped_child(pid) {
assert_ne!(
block.ready(),
Some(false),
"the wait blocked with nothing left to wake it, after the kernel reaped pid {pid}"
);
}
})
}
fn ignoring_sigchld_with_a_sibling() -> (
OwnedChild,
std::process::Child,
(crate::wait::block_probe::Armed, crate::wait::block_probe::Armed),
) {
crate::test_child::set_signal_ignored(libc::SIGCHLD, true);
let sibling = blocker().into_inner();
let (root, root_stdin) = blocker().into_parts();
let root_pid = root.id();
let id = super::fixtures::identity_of(&root);
let owned = OwnedChild::adopt(root, id, TrackedKind::Own).unwrap_or_else(|(e, _)| panic!("adopt: {e}"));
let mut root_stdin = Some(root_stdin);
let end = crate::wait::block_probe::on_blocking(move || drop(root_stdin.take()));
let reaped = no_block_after_the_kernel_reaps(root_pid);
(owned, sibling, (end, reaped))
}
#[skuld::test]
fn a_wait_on_a_child_the_kernel_reaped_returns_while_a_sibling_lives() {
if !crate::test_child::is_marked_fixture_reexec(MARKER) {
return run_case(
crate::test_child::fixture_path!(a_wait_on_a_child_the_kernel_reaped_returns_while_a_sibling_lives),
"",
);
}
let (owned, _sibling, _end) = ignoring_sigchld_with_a_sibling();
let outcome = owned.wait(None);
assert!(is_foreign(&outcome), "the kernel reaped the root: {outcome:?}");
}
#[skuld::test]
fn a_wait_timeout_far_past_the_bound_returns_echild() {
if !crate::test_child::is_marked_fixture_reexec(MARKER) {
return run_case(
crate::test_child::fixture_path!(a_wait_timeout_far_past_the_bound_returns_echild),
"",
);
}
let (owned, _sibling, _end) = ignoring_sigchld_with_a_sibling();
let outcome = owned.wait(Some(far()));
assert!(is_foreign(&outcome), "the kernel reaped the root: {outcome:?}");
}
#[skuld::test]
fn a_sync_drop_of_a_child_the_kernel_reaped_returns() {
if !crate::test_child::is_marked_fixture_reexec(MARKER) {
return run_case(
crate::test_child::fixture_path!(a_sync_drop_of_a_child_the_kernel_reaped_returns),
"",
);
}
crate::test_child::set_signal_ignored(libc::SIGCHLD, true);
#[allow(clippy::zombie_processes, reason = "the kernel reaps it: SIGCHLD is ignored")]
let _sibling = blocker().into_inner();
use std::io::Read as _;
let mut cmd = crate::test_child::command(Console::Hidden);
cmd.args(["sh", "-c", "cat; echo eof"]);
let (stdin, writer) = crate::test_child::held_writer_stdin();
let teardown = crate::child::spawn::fault::release_at_drop_kill(writer);
cmd.stdin(stdin).expect("stdin");
cmd.stdout(crate::Stdio::pipe()).expect("stdout");
let mut child = cmd.spawn().expect("spawn");
let mut stdout = child.stdout().expect("piped stdout");
let _no_late_block = no_block_after_the_kernel_reaps(child.pid());
drop(child);
teardown.assert_released();
let mut printed = Vec::new();
stdout
.read_to_end(&mut printed)
.expect("the pipe ends once `cat` is gone");
assert!(
printed.is_empty(),
"the drop's kill must end the shell first: {printed:?}"
);
}
#[skuld::test]
fn try_wait_on_a_pid_with_another_unique_id_is_echild_and_consumes_nothing() {
let (mut b, _) =
Blocker::spawn_over(|pid, unique| FakeKernel::over(&HostKernel).on_unique_info(pid, found(unique ^ 1)));
b.end_child_and_confirm_exit();
let outcome = try_wait(&b.owned);
assert!(is_foreign(&outcome), "another process holds the pid: {outcome:?}");
wait_status(&b.owned);
}
#[skuld::test]
fn a_wait_on_a_pid_with_another_unique_id_never_reaches_the_reap() {
let (mut b, _) =
Blocker::spawn_over(|pid, unique| FakeKernel::over(&HostKernel).on_unique_info(pid, found(unique ^ 1)));
b.end_child_and_confirm_exit();
let outcome = b.owned.wait(None);
assert!(is_foreign(&outcome), "another process holds the pid: {outcome:?}");
wait_status(&b.owned);
}
#[skuld::test]
fn kill_sends_nothing_to_a_pid_with_another_unique_id() {
let (mut b, _) =
Blocker::spawn_over(|pid, unique| FakeKernel::over(&HostKernel).on_unique_info(pid, found(unique ^ 1)));
let log = crate::send_log::Capture::start();
b.owned
.signal(Sig::Kill)
.expect("a pid that is not ours is gone, not an error");
assert_eq!(log.entries(), []);
b.end_child();
let status = wait_status(&b.owned);
assert!(status.success(), "the child was signalled: {status:?}");
}
#[skuld::test]
fn kill_signals_a_live_child_through_its_audit_token() {
let b = Blocker::spawn();
let log = crate::send_log::Capture::start();
b.owned.signal(Sig::Kill).expect("kill");
assert_eq!(log.entries(), [(b.pid, Sig::Kill, crate::send_log::Via::Identity)]);
let status = wait_status(&b.owned);
assert_eq!(super::fixtures::signal_of(status), Some(libc::SIGKILL));
}
#[skuld::test]
fn kill_on_an_own_unreaped_zombie_is_delivered() {
let mut b = Blocker::spawn();
b.end_child_and_confirm_exit();
assert_eq!(b.owned.signal(Sig::Kill).expect("kill"), crate::signal::Sent::Delivered);
let status = wait_status(&b.owned);
assert!(status.success(), "{status:?}");
}
pub(super) fn watch(kernel: impl Kernel + Send + 'static, pid: u32, unique: u64) -> OwnedChild {
let mac = MacosChild::new(kernel, pid, unique).expect("watch the child");
OwnedChild::new(Box::new(mac), TrackedKind::Own)
}
fn held_by_whom(pid: u32, holder: &Arc<AtomicU32>) -> FakeKernel<'static> {
let holder = Arc::clone(holder);
FakeKernel::over(&HostKernel)
.on_every_short_bsd(pid, move || Ok(short_info_held_by(pid, holder.load(Ordering::SeqCst))))
}
#[skuld::test]
fn a_wait_on_a_child_whose_tracer_dies_during_its_exit_is_woken_by_the_tracers_exit() {
let (pid, unique) = echild_yet_resolvable();
let mut tracer = blocker();
let tracer_stdin = tracer.stdin.take().expect("piped stdin");
let tracer_pid = tracer.id();
let holder = Arc::new(AtomicU32::new(tracer_pid));
let owned = watch(held_by_whom(pid, &holder), pid, unique);
let _end = crate::wait::block_probe::on_blocking(move || {
drop(tracer_stdin);
crate::test_child::wait_until_zombie(tracer_pid);
holder.store(LAUNCHD, Ordering::SeqCst);
});
let _ = test_hooks::take_events();
let outcome = owned.wait(None).expect("wait");
let events = test_hooks::take_events();
assert!(
events
.iter()
.any(|&(filter, fflags)| filter == libc::EVFILT_PROC && fflags & libc::NOTE_EXIT != 0),
"the tracer's exit must wake the wait: {events:?}"
);
assert_eq!(outcome, ChildWaitOutcome::Foreign(Foreign::Orphaned));
}
#[derive(Clone, Default)]
pub(super) struct Looks(std::rc::Rc<std::cell::RefCell<Vec<Look>>>);
type Look = (u32, Option<bool>);
impl Looks {
pub(super) fn get(&self) -> Vec<Look> {
self.0.borrow().clone()
}
}
pub(super) fn on_rounds(mut hook: impl FnMut(u32) -> bool + 'static) -> (crate::wait::block_probe::Armed, Looks) {
let looks = Looks::default();
let armed = crate::wait::block_probe::on_each_block({
let looks = looks.clone();
move |block| {
let Some(n) = block.n else { return };
let round = n - 1;
if hook(round) {
let look = block.ready();
looks.0.borrow_mut().push((round, look));
if look == Some(true) {
return;
}
}
test_hooks::send_signal(std::process::id(), libc::SIGCHLD);
}
});
(armed, looks)
}
#[skuld::test]
fn a_wait_on_a_child_a_tracer_attaches_to_late_is_woken_by_the_attach() {
use std::cell::RefCell;
let (pid, unique) = echild_yet_resolvable();
let mut tracer = blocker();
let tracer_stdin = tracer.stdin.take().expect("piped stdin");
let tracer_pid = tracer.id();
let holder = Arc::new(AtomicU32::new(pid));
let owned = watch(held_by_whom(pid, &holder), pid, unique);
let tracer_stdin = RefCell::new(Some(tracer_stdin));
let (_rounds, looks) = on_rounds(move |round| match round {
0 => {
holder.store(tracer_pid, Ordering::SeqCst);
test_hooks::send_signal(pid, libc::SIGCONT);
true
}
1 => {
drop(tracer_stdin.borrow_mut().take());
crate::test_child::wait_until_zombie(tracer_pid);
holder.store(LAUNCHD, Ordering::SeqCst);
true
}
_ => false,
});
let outcome = owned.wait(None);
assert_eq!(
looks.get(),
[(0, Some(true)), (1, Some(true))],
"the attach's SIGCONT, then the tracer's exit, must each leave the wait an event to wake on"
);
assert_eq!(outcome.expect("wait"), ChildWaitOutcome::Foreign(Foreign::Orphaned));
}
fn started_by_us_traced_by(pid: u32, tracer: u32) -> kinfo_proc {
kinfo_proc::of_host_held_by(pid, std::process::id() as libc::pid_t, tracer as libc::pid_t)
}
#[skuld::test]
fn a_wait_on_a_child_whose_tracer_is_traced_is_woken_by_that_tracers_exit() {
let (pid, unique) = echild_yet_resolvable();
let tracer = blocker();
let outer = blocker();
let (tracer_pid, outer_pid) = (tracer.id(), outer.id());
let holder = Arc::new(AtomicU32::new(tracer_pid));
let kernel =
held_by_whom(pid, &holder).on_every_kinfo(tracer_pid, move || started_by_us_traced_by(tracer_pid, outer_pid));
let owned = watch(kernel, pid, unique);
let (_rounds, looks) = on_rounds(move |round| {
if round != 0 {
return false;
}
holder.store(LAUNCHD, Ordering::SeqCst);
test_hooks::send_signal(outer_pid, libc::SIGCHLD);
true
});
let outcome = owned.wait(None);
assert_eq!(
looks.get(),
[(0, Some(true))],
"the SIGCHLD to the tracer's tracer must leave the wait an event to wake on"
);
assert_eq!(outcome.expect("wait"), ChildWaitOutcome::Foreign(Foreign::Orphaned));
}
#[skuld::test]
fn a_wait_on_a_child_whose_tracer_is_exiting_at_launchd_peeks_again_on_a_backoff() {
let (pid, unique) = echild_yet_resolvable();
let tracer = blocker();
let tracer_pid = tracer.id();
let holder = Arc::new(AtomicU32::new(tracer_pid));
let kernel =
held_by_whom(pid, &holder).on_every_kinfo(tracer_pid, move || started_by_us_traced_by(tracer_pid, LAUNCHD));
let owned = watch(kernel, pid, unique);
let _pause = crate::wait::block_probe::on_pause({
let holder = Arc::clone(&holder);
move || holder.store(LAUNCHD, Ordering::SeqCst)
});
let _rounds = on_rounds(move |round| {
holder.store(LAUNCHD, Ordering::SeqCst);
round != 0
});
crate::wait::block_probe::take();
let outcome = owned.wait(None).expect("wait");
let armed = crate::wait::block_probe::take();
assert!(
matches!(armed.first(), Some(Some(_))),
"the first block must be a timed pause, to look again: {armed:?}"
);
assert_eq!(outcome, ChildWaitOutcome::Foreign(Foreign::Orphaned));
}
#[skuld::test]
fn a_running_peek_of_a_pid_with_another_unique_id_is_foreign() {
let (mut b, _) = Blocker::spawn_over(|pid, unique| {
FakeKernel::over(&HostKernel)
.on_unique_info(pid, found(unique ^ 1))
.on_unique_info(pid, UniqRead::Refused(libc::EPERM))
.on_unique_info(pid, found(unique))
});
let outcome = try_wait(&b.owned);
assert!(is_foreign(&outcome), "another process holds the pid: {outcome:?}");
for why in ["a refused id read", "a matching id"] {
assert_eq!(
try_wait(&b.owned).expect("try_wait"),
ChildWaitOutcome::DeadlinePassed,
"{why}"
);
}
b.end_child();
wait_status(&b.owned);
}
#[skuld::test]
fn a_wait_on_a_zombie_launchd_holds_warns_it_is_not_ours_to_reap() {
crate::log_capture::install();
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");
let mut child = cmd.spawn().expect("spawn");
let pid = child.pid();
drop(writer);
crate::test_child::wait_until_zombie(pid);
let mark = crate::log_capture::mark();
child
.proc
.script_over(|f| f.reaps([crate::os_process::fake::ReapAnswer::Foreign(Foreign::Orphaned)]));
_ = child.wait();
let records = crate::log_capture::records_since_on_current_thread(mark, &format!("pid {pid}"));
assert!(
records
.iter()
.any(|(level, text)| *level == log::Level::Warn && text.contains("not ours to reap")),
"{records:?}"
);
drop(child);
}
#[skuld::test]
fn a_drop_that_finds_no_exit_record_after_the_wait_saw_one_consumes_nothing() {
let (mut b, kernel) = Blocker::spawn_over(|pid, _| {
FakeKernel::over(&HostKernel)
.on_peek(pid, Ok(Some(exit_record(0))))
.on_peek(pid, Ok(None))
});
b.end_child_and_confirm_exit();
let status = wait_status(&b.owned);
assert!(status.success(), "{status:?}");
let pid = b.pid;
drop(b);
assert!(kernel.all_rows_taken(), "the wait and the drop must each peek");
assert!(
crate::test_child::is_unreaped_child(pid),
"the drop consumed a zombie its own peek did not find"
);
crate::test_child::reaped_elsewhere::reap_behind(pid);
}
fn spawn_root_child() -> (std::process::Child, std::process::ChildStdin) {
use std::io::Read as _;
let helper = crate::test_privilege::setuid::setuid_helper();
let mut cmd = std::process::Command::new(helper);
cmd.args(["setuid-stdin-block", "root"])
.stdin(std::process::Stdio::piped())
.stdout(std::process::Stdio::piped())
.stderr(std::process::Stdio::null());
let mut child = crate::test_spawn::spawn(&mut cmd).expect("spawn the setuid helper");
let stdin = child.stdin.take().expect("piped stdin");
let mut ready = [0u8; 1];
child
.stdout
.take()
.expect("piped stdout")
.read_exact(&mut ready)
.expect("the helper reports ready");
assert_eq!(ready, *b"+");
(child, stdin)
}
#[skuld::test]
fn setuid_kill_of_a_root_child_is_permission_denied(#[fixture(setuid)] _group: &Group) {
let (child, stdin) = spawn_root_child();
let id = super::fixtures::identity_of(&child);
unique_of(id.pid());
let owned = OwnedChild::adopt(child, id, TrackedKind::Own).unwrap_or_else(|(e, _)| panic!("adopt: {e}"));
let err = owned
.signal(Sig::Kill)
.expect_err("this caller may not signal a root process")
.into_io();
assert_eq!(err.kind(), std::io::ErrorKind::PermissionDenied, "{err}");
drop(stdin);
let status = wait_status(&owned);
assert!(status.success(), "{status:?}");
}
#[skuld::test]
fn setuid_child_kill_is_permission_denied(#[fixture(setuid)] _group: &Group) {
let (child, stdin) = crate::test_privilege::spawn_setuid_blocker();
let err = child.kill().expect_err("this caller may not signal a root process");
assert!(
matches!(&err, crate::error::Error::Io(e) if e.kind() == std::io::ErrorKind::PermissionDenied),
"{err:?}"
);
drop(stdin);
let status = child.wait().expect("the helper exits on EOF");
assert!(status.success(), "{status:?}");
}
#[skuld::test]
fn a_refused_id_read_at_the_exit_check_consumes_nothing() {
let (mut b, _) = Blocker::spawn_over(|pid, _| {
FakeKernel::over(&HostKernel)
.on_unique_info(pid, UniqRead::Refused(libc::EPERM))
.on_unique_info(pid, UniqRead::Refused(libc::EACCES))
});
b.end_child_and_confirm_exit();
let err = try_wait(&b.owned)
.expect_err("an unverifiable exit is not consumed")
.into_io();
assert_eq!(err.kind(), std::io::ErrorKind::PermissionDenied, "{err}");
let err = b.owned.wait(None).expect_err("nor by a wait").into_io();
assert_eq!(err.kind(), std::io::ErrorKind::PermissionDenied, "{err}");
let status = wait_status(&b.owned);
assert!(status.success(), "{status:?}");
}
#[skuld::test]
fn a_try_wait_during_a_holders_wait_does_not_strand_the_holder() {
let mut b = Blocker::spawn();
let (reached_tx, reached_rx) = std::sync::mpsc::channel();
let (staged_tx, staged_rx) = std::sync::mpsc::channel::<()>();
let holder = std::thread::spawn({
let owned = std::sync::Arc::clone(&b.owned);
move || {
let _blocking = crate::wait::block_probe::on_blocking(move || {
_ = reached_tx.send(());
staged_rx.recv().expect("the test stages the exit");
});
owned.wait(None)
}
});
reached_rx.recv().expect("the holder must reach its wait");
b.end_child_and_confirm_exit();
let peeked = status(try_wait(&b.owned));
assert!(peeked.success(), "{peeked:?}");
staged_tx.send(()).expect("the holder is waiting for the stage");
let status = status(holder.join().expect("holder"));
assert!(status.success(), "{status:?}");
}
#[skuld::test]
fn try_wait_during_a_wait_errors_when_a_running_childs_unique_id_is_unreadable() {
use std::sync::atomic::{AtomicBool, Ordering};
let refused = Arc::new(AtomicBool::new(false));
let (mut b, _) = Blocker::spawn_over({
let refused = Arc::clone(&refused);
move |pid, unique| {
FakeKernel::over(&HostKernel).on_every_unique_info(pid, move || {
if refused.load(Ordering::SeqCst) {
UniqRead::Refused(libc::EPERM)
} else {
found(unique)
}
})
}
});
let (reached_tx, reached_rx) = std::sync::mpsc::channel();
let (staged_tx, staged_rx) = std::sync::mpsc::channel::<()>();
let holder = std::thread::spawn({
let owned = Arc::clone(&b.owned);
move || {
let _blocking = crate::wait::block_probe::on_blocking(move || {
_ = reached_tx.send(());
staged_rx.recv().expect("the test stages the refusal");
});
owned.wait(None)
}
});
reached_rx.recv().expect("the holder must reach its wait");
refused.store(true, Ordering::SeqCst);
let err = try_wait(&b.owned)
.expect_err("a running child that cannot be shown to be ours")
.into_io();
assert_eq!(err.kind(), std::io::ErrorKind::PermissionDenied, "{err}");
refused.store(false, Ordering::SeqCst);
staged_tx.send(()).expect("the holder is waiting for the stage");
b.end_child();
let status = status(holder.join().expect("holder"));
assert!(status.success(), "{status:?}");
}
#[skuld::test]
fn a_try_wait_that_drains_note_exit_then_a_wait_still_returns() {
use std::cell::Cell;
use std::rc::Rc;
let (mut b, kernel) = Blocker::spawn_over(|pid, _| {
FakeKernel::over(&HostKernel)
.on_peek(pid, Ok(None))
.on_peek(pid, Ok(None))
});
b.end_child_and_confirm_exit();
assert_eq!(try_wait(&b.owned).expect("try_wait"), ChildWaitOutcome::DeadlinePassed);
let blocked = Rc::new(Cell::new(false));
let _end = crate::wait::block_probe::on_each_block({
let blocked = Rc::clone(&blocked);
move |_| {
blocked.set(true);
test_hooks::send_signal(std::process::id(), libc::SIGCHLD);
}
});
let status = wait_status(&b.owned);
assert!(
!blocked.get(),
"the wait must pause and look again, not block on an empty queue"
);
assert!(status.success(), "{status:?}");
assert!(kernel.all_rows_taken(), "the try_wait and the wait must each peek");
}
#[skuld::test]
fn a_refused_confirmation_is_dead_when_the_peek_shows_the_exit_record() {
let (mut b, _) =
Blocker::spawn_over(|pid, _| FakeKernel::over(&HostKernel).on_unique_info(pid, UniqRead::Refused(libc::EPERM)));
b.end_child_and_confirm_exit();
assert!(
matches!(b.owned.liveness(), Ok(crate::identity::Liveness::Dead)),
"the exit record is visible whatever the confirming read says"
);
let reaped = status(try_wait(&b.owned));
assert!(reaped.success(), "{reaped:?}");
}
#[skuld::test]
fn a_refused_confirmation_is_the_refusal_when_the_peek_reads_the_child_running() {
let (b, kernel) = Blocker::spawn_over(|pid, _| {
FakeKernel::over(&HostKernel)
.on_subscribe_refused(ExitWatch::registration(pid), libc::ESRCH)
.on_unique_info(pid, UniqRead::Refused(libc::EPERM))
});
let err = b.owned.liveness().expect_err("a running peek does not answer");
assert!(matches!(err, Error::Unassessable { .. }), "{err:?}");
assert_eq!(crate::error::first_os_code(&err), Some(libc::EPERM), "{err:?}");
assert!(
kernel.all_rows_taken(),
"the adoption's registration was refused, and the confirming read was refused"
);
}