From 88cc95c59f9e98891b76c3825108aa02fce23992 Mon Sep 17 00:00:00 2001 From: chris west Date: Sat, 23 May 2020 12:19:15 -0700 Subject: [PATCH] don't quit parent when child receives SIGINT --- src/ui.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ui.rs b/src/ui.rs index 89562c4..5752e34 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -66,13 +66,17 @@ lazy_static! { static ref RESIZE_SENDER: Arc>>> = Arc::new(Mutex::new(None)); } -/// Raw resize handler that is called when SIGWINCH is receiver. +/// Raw resize handler that is called when SIGWINCH is received. fn resize_handler(_: i32) { if let Some(sender) = &*RESIZE_SENDER.lock().unwrap() { sender.send(Key::F(5)).unwrap(); } } +/// No-op INT handler that is called when SIGINT (ctrl-c) is +/// received in child processes (like `telnet`). +fn sigint_handler(_: i32) {} + /// UI is mainly concerned with drawing to the screen, managing the /// active views, and responding to user input. pub struct UI { @@ -521,6 +525,7 @@ impl UI { *RESIZE_SENDER.lock().unwrap() = Some(sender.clone()); unsafe { libc::signal(libc::SIGWINCH, resize_handler as usize); + libc::signal(libc::SIGINT, sigint_handler as usize); } thread::spawn(move || {