cosca 0.10.0

Unified cross-platform subprocess management: spawning, stdio, process trees, stable identity, and elevation.
Documentation
//! `real_round` on a real kqueue.

use std::time::Duration;

use crate::os_process::macos::kqueue::{Kqueue, Subscription};
use crate::test_child::blocker_with;

/// A timeout beyond XNU's `kevent` limit still delivers a pending exit instead of panicking. The
/// child blocks on a pipe until `NOTE_EXIT` is armed, since XNU refuses to arm it on an exited
/// process (`ESRCH`).
///
/// Mutant: build the timespec inline, unclamped -> `kevent failed: EINVAL`.
#[skuld::test]
fn real_round_with_a_far_timeout_returns_the_pending_exit() {
    let mut child = blocker_with(|cat| {
        cat.stdout(std::process::Stdio::null());
    });
    let stdin = child.stdin.take().expect("cat's stdin is piped");
    let kq = Kqueue::new().expect("kqueue");
    let exit = Subscription::Process {
        pid: child.id(),
        signals: false,
        reap: false,
    };
    kq.subscribe(exit).expect("arm NOTE_EXIT");
    drop(stdin);
    let batch = super::real_round(
        &kq,
        &mut super::SignalPipe::default(),
        Some(Duration::from_secs(u64::from(u32::MAX))),
    );
    assert!(batch.note_exit, "the exit is delivered, not an EINVAL panic");
    child.wait().expect("reap");
}