From 478d7e8bcaea6a1afd94ea3053d4a3d495634ae2 Mon Sep 17 00:00:00 2001 From: ArthurSonzogni Date: Sat, 19 Jun 2021 18:44:43 +0200 Subject: [PATCH] On SIGINT, raise signal again. When SIGINT is intercepted, quit the run loop and raise the signal again. I am not sure this addresses: https://github.com/ArthurSonzogni/FTXUI/issues/117 Maybe? --- src/ftxui/component/screen_interactive.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ftxui/component/screen_interactive.cpp b/src/ftxui/component/screen_interactive.cpp index 0b45c6e1..10f8e46b 100644 --- a/src/ftxui/component/screen_interactive.cpp +++ b/src/ftxui/component/screen_interactive.cpp @@ -205,9 +205,7 @@ void OnExit(int signal) { on_exit_functions.top()(); on_exit_functions.pop(); } - - if (signal == SIGINT) - std::exit(SIGINT); + std::raise(signal); } auto install_signal_handler = [](int sig, SignalHandler handler) { @@ -278,6 +276,8 @@ CapturedMouse ScreenInteractive::CaptureMouse() { } void ScreenInteractive::Loop(Component component) { + on_exit_functions.push([this] { ExitLoopClosure()(); }); + // Install a SIGINT handler and restore the old handler on exit. auto old_sigint_handler = std::signal(SIGINT, OnExit); on_exit_functions.push(