From b4112743cff42452b5d18558bf2d55bbbfff8c69 Mon Sep 17 00:00:00 2001 From: Matt Coles Date: Thu, 30 Jul 2026 14:46:01 -0700 Subject: fix(client): restore terminal on sighup and sigterm Enable termination-signal handling so SIGHUP and SIGTERM follow the graceful quit path and restore terminal state. Log handler registration failures and add PTY coverage for direct SIGHUP and server EOF restoration Co-authored-by: Matt Coles --- src/client/mod.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/client') diff --git a/src/client/mod.rs b/src/client/mod.rs index 6be41c06..52fd6dd6 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -1225,11 +1225,14 @@ fn run_client_with_mode( let should_quit = Arc::new(AtomicBool::new(false)); - // Install Ctrl+C handler. + // ctrlc's "termination" feature also catches SIGTERM/SIGHUP so direct + // termination signals still run the quit path and TerminalGuard::Drop. let quit_flag = should_quit.clone(); - let _ = ctrlc::set_handler(move || { + if let Err(err) = ctrlc::set_handler(move || { quit_flag.store(true, Ordering::Release); - }); + }) { + warn!(%err, "failed to install termination handler; terminal restore relies on TerminalGuard::Drop and the panic hook"); + } let result = rt.block_on(async { run_client_loop( -- cgit v1.2.3