diff --git a/src/main.cc b/src/main.cc index 1a993c98..dc25efc8 100644 --- a/src/main.cc +++ b/src/main.cc @@ -357,6 +357,7 @@ std::unique_ptr create_local_ui(UIType ui_type) local_ui = this; m_old_sighup = set_signal_handler(SIGHUP, [](int) { ClientManager::instance().remove_client(*local_client, false); + static_cast(local_ui)->on_sighup(); }); m_old_sigtstp = set_signal_handler(SIGTSTP, [](int) { @@ -373,9 +374,8 @@ std::unique_ptr create_local_ui(UIType ui_type) raise(SIGTSTP); - sigprocmask(SIG_SETMASK, &old_mask, nullptr); - set_signal_handler(SIGTSTP, current); + sigprocmask(SIG_SETMASK, &old_mask, nullptr); } else convert_to_client_pending = true; diff --git a/src/ncurses_ui.cc b/src/ncurses_ui.cc index e3c235ee..5d3627df 100644 --- a/src/ncurses_ui.cc +++ b/src/ncurses_ui.cc @@ -480,8 +480,19 @@ void NCursesUI::check_resize(bool force) werase(curscr); } +void NCursesUI::on_sighup() +{ + set_signal_handler(SIGWINCH, SIG_DFL); + set_signal_handler(SIGCONT, SIG_DFL); + + m_window = nullptr; +} + bool NCursesUI::is_key_available() { + if (not m_window) + return false; + check_resize(); wtimeout(m_window, 0); @@ -492,7 +503,6 @@ bool NCursesUI::is_key_available() return c != ERR; } - Key NCursesUI::get_key() { check_resize(); diff --git a/src/ncurses_ui.hh b/src/ncurses_ui.hh index 1b094c1d..6efbbcea 100644 --- a/src/ncurses_ui.hh +++ b/src/ncurses_ui.hh @@ -59,6 +59,10 @@ public: DisplayCoord pos; DisplayCoord size; }; + +protected: + void on_sighup(); + private: void check_resize(bool force = false); void redraw();