diff --git a/apps/fieldcraft/Cargo.toml b/apps/fieldcraft/Cargo.toml index c88b832..c5dc9d4 100644 --- a/apps/fieldcraft/Cargo.toml +++ b/apps/fieldcraft/Cargo.toml @@ -25,7 +25,7 @@ ureq = { version = "3.4", default-features = false, features = ["rustls-no-provi rustls = { version = "0.23", default-features = false, features = ["ring", "std"] } getrandom = "0.3" -# A termination signal (SIGTERM, SIGINT, SIGHUP) closes the window the normal way (terminate.rs). +# A termination signal (SIGTERM, SIGINT) closes the window the normal way (terminate.rs). [target.'cfg(unix)'.dependencies] signal-hook = "0.3" diff --git a/apps/fieldcraft/src/main.rs b/apps/fieldcraft/src/main.rs index f114a67..9da2e34 100644 --- a/apps/fieldcraft/src/main.rs +++ b/apps/fieldcraft/src/main.rs @@ -268,7 +268,7 @@ fn main() -> eframe::Result { log::info!("graphics {:?} {} ({}), MSAA {}x (requested {MSAA}x)", info.backend, info.name, info.driver, rs.msaa_samples); app.set_wgpu(rs, DEPTH_BITS, rs.msaa_samples, &cc.egui_ctx); } - // `kill`, Ctrl-C or a logout closes the window as Close does: autosaved, no crash (#248). + // `kill` or Ctrl-C closes the window as Close does: autosaved, no crash (#248). let ctx = cc.egui_ctx.clone(); if let Err(e) = terminate::watch(move || { ctx.send_viewport_cmd(egui::ViewportCommand::Close); diff --git a/apps/fieldcraft/src/terminate.rs b/apps/fieldcraft/src/terminate.rs index 6546286..498acd5 100644 --- a/apps/fieldcraft/src/terminate.rs +++ b/apps/fieldcraft/src/terminate.rs @@ -1,6 +1,6 @@ -//! A request to terminate (SIGTERM, SIGINT, SIGHUP on Unix) closes the window the normal way. +//! A request to terminate (SIGTERM, SIGINT on Unix) closes the window the normal way. //! -//! Without this, `kill PID`, Ctrl-C in the terminal, a session logout or a test harness's timeout +//! Without this, `kill PID`, Ctrl-C in the terminal, a system shutdown or a test harness's timeout //! ended the process on the spot: no `on_exit`, so no last autosave and no clean end of the crash //! journal, and the next start filed an `unclean_exit` crash report for what was no crash (#248: //! "ended without a clean exit between commands (last: control ui.capture)" was an automation run @@ -9,6 +9,10 @@ //! so a run that still dies while closing says why. A second signal, for a window that does not //! close, ends the process at once with the signal's default action. //! +//! SIGHUP is left alone: `nohup fieldcraft &` ignores it on purpose so the app outlives its +//! terminal, and a handler would override that (a safe API cannot ask whether a signal was +//! ignored at launch). +//! //! Windows has no such signals: a window there is closed through its messages, which eframe //! already turns into a normal close. @@ -16,7 +20,7 @@ use std::io; /// The signals that ask the app to terminate. #[cfg(unix)] -const SIGNALS: [i32; 3] = [signal_hook::consts::SIGTERM, signal_hook::consts::SIGINT, signal_hook::consts::SIGHUP]; +const SIGNALS: [i32; 2] = [signal_hook::consts::SIGTERM, signal_hook::consts::SIGINT]; /// The signal's usual name, for the log and the crash journal. #[cfg(unix)] @@ -24,7 +28,6 @@ fn name(signal: i32) -> &'static str { match signal { signal_hook::consts::SIGTERM => "SIGTERM", signal_hook::consts::SIGINT => "SIGINT", - signal_hook::consts::SIGHUP => "SIGHUP", _ => "signal", } } diff --git a/docs/crash-reports.md b/docs/crash-reports.md index de052a8..dc1eabf 100644 --- a/docs/crash-reports.md +++ b/docs/crash-reports.md @@ -78,8 +78,8 @@ diagnostics.bug_report` opens the form, `ui.prompt {"answer": "set", …}` sets **Check that reporting works:** with `FIELDCRAFT_CRASH_TEST=1`, `diagnostics.crash_test {mode}` crashes on purpose: `panic`, `recovered` or `abort` (reported at the next start). -A request to terminate is no crash: on Linux and macOS, SIGTERM (`kill PID`), SIGINT (Ctrl-C) -and SIGHUP close the window as **Close** does (unsaved work is autosaved for recovery, the +A request to terminate is no crash: on Linux and macOS, SIGTERM (`kill PID`) and SIGINT (Ctrl-C) +close the window as **Close** does (unsaved work is autosaved for recovery, the journal ends, no report). A second signal ends the app at once. ### How it stays cheap and small