Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/edda

crates/appliance-pid1/tests/sigpwr_stops.rs

//! **SIGPWR is a request to stop** (2026-09-30, estate-box D1: a process box's power button
//! is SIGTERM to its program, then SIGPWR — a UPS daemon's and a container runtime's power
//! signal). A PID 1 with no handler for it is ended by the kernel's default action (a
//! process) or deaf to it (PID 1 of a namespace); `shutdown_signal` now names it and the
//! payload stops cleanly.
#![cfg(feature = "runtime")]

#[tokio::test(flavor = "current_thread")]
async fn sigpwr_is_heard_and_named_like_sigterm() {
    let waiting = tokio::spawn(appliance_pid1::runtime::shutdown_signal());
    // Let the handlers install before the signal is raised.
    for _ in 0..10 {
        tokio::task::yield_now().await;
    }
    tokio::time::sleep(std::time::Duration::from_millis(100)).await;
    // SAFETY: raise(3) on this test process; the handler is installed above.
    unsafe { libc::raise(libc::SIGPWR) };
    let said = tokio::time::timeout(std::time::Duration::from_secs(5), waiting).await.expect("heard within 5 s").expect("the task");
    assert_eq!(said, "SIGPWR");
}