Catch SIGINT event.

This was an old features, but it has been removed mistakenly when
merging some patches.

This allow the terminal to be restored when the user kill the
application.
This commit is contained in:
ArthurSonzogni 2020-05-01 23:45:17 +02:00
parent d8e0504ad0
commit 898cd842e2

View File

@ -211,6 +211,11 @@ void ScreenInteractive::Loop(Component* component) {
// Handle resize. // Handle resize.
on_resize = [&] { event_sender_->Send(Event::Special({0})); }; on_resize = [&] { event_sender_->Send(Event::Special({0})); };
install_signal_handler(SIGWINCH, OnResize); 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 #endif
// Hide the cursor and show it at exit. // Hide the cursor and show it at exit.