app: leave SIGHUP alone so nohup keeps the app running (#248 follow-up)

#445 also closed the window on SIGHUP, which overrides the SIG_IGN that
`nohup fieldcraft &` sets so the app outlives its terminal. A safe API cannot
ask whether a signal was ignored at launch, so SIGHUP keeps its default.
SIGTERM and SIGINT still close the window the normal way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UhhZMBTviDQxZvwnyP89fo
This commit is contained in:
jyvikoandClaude Opus 5.5 authored and Irakli Kourtis committed 2026-10-16 00:47:35 -04:00
1 parent 9a30c7d9ed
commit 7a5363e07b
4 files changed
+11 -8

No files matched your search

+1 -1
View File
@@ -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"
+1 -1
View File
@@ -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);
+7 -4
View File
@@ -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",
}
}
+2 -2
View File
@@ -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