From 2d292b538279394acd310becdc2650f131a1ace2 Mon Sep 17 00:00:00 2001 From: ArthurSonzogni Date: Fri, 1 May 2020 23:48:22 +0200 Subject: [PATCH] Make catching SIGNAL SIGINT to work also on windows. --- src/ftxui/component/screen_interactive.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ftxui/component/screen_interactive.cpp b/src/ftxui/component/screen_interactive.cpp index aeea098..58ee31d 100644 --- a/src/ftxui/component/screen_interactive.cpp +++ b/src/ftxui/component/screen_interactive.cpp @@ -176,6 +176,11 @@ void ScreenInteractive::PostEvent(Event event) { } void ScreenInteractive::Loop(Component* component) { + // Install a SIGINT handler and restore the old handler on exit. + auto old_sigint_handler = std::signal(SIGINT, OnExit); + on_exit_functions.push( + [old_sigint_handler]() { std::signal(SIGINT, old_sigint_handler); }); + // Save the old terminal configuration and restore it on exit. #if defined(_WIN32) // Enable VT processing on stdout and stdin @@ -211,11 +216,6 @@ void ScreenInteractive::Loop(Component* component) { // Handle resize. on_resize = [&] { event_sender_->Send(Event::Special({0})); }; install_signal_handler(SIGWINCH, OnResize); - - // Install a SIGINT handler and restore the old handler on exit. - auto old_sigint_handler = std::signal(SIGINT, OnExit); - on_exit_functions.push( - [old_sigint_handler]() { std::signal(SIGINT, old_sigint_handler); }); #endif // Hide the cursor and show it at exit.