use crate::identity::ProcessId;
#[test]
fn drain_reports_none_when_no_event_pending() {
let _guard = crate::child::spawn::spawn_lock();
let mut child = std::process::Command::new("sleep")
.arg("30")
.spawn()
.expect("spawn blocker");
let id = ProcessId::of(child.id()).found().expect("identity of live child");
let kq = super::arm_proc_exit(id).expect("arm").expect("a live child arms");
assert!(
super::drain_proc_exit(&kq).expect("drain").is_none(),
"no exit event yet must drain to None (spurious-readiness input)"
);
child.kill().expect("cleanup");
child.wait().expect("reap");
}
#[test]
fn a_pid_zero_identity_never_reaches_kill() {
let bogus = crate::identity::ProcessId::from_parts_for_test(0, 1);
crate::wait::kill(bogus).expect("a pid-0 identity resolves to a stranger, i.e. already gone");
crate::wait::terminate(bogus).expect("same for the graceful signal");
assert_eq!(
crate::identity::ProcessId::current().is_alive(),
crate::identity::Liveness::Alive,
"the caller must have survived - nothing may signal process group 0"
);
}