More correct handling of SIGHUP while suspended

Fixes #833
This commit is contained in:
Maxime Coste 2016-11-14 00:49:34 +00:00
parent 5249df78d4
commit c2989704d5
3 changed files with 17 additions and 3 deletions

View File

@ -357,6 +357,7 @@ std::unique_ptr<UserInterface> 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<LocalUI*>(local_ui)->on_sighup();
});
m_old_sigtstp = set_signal_handler(SIGTSTP, [](int) {
@ -373,9 +374,8 @@ std::unique_ptr<UserInterface> 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;

View File

@ -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();

View File

@ -59,6 +59,10 @@ public:
DisplayCoord pos;
DisplayCoord size;
};
protected:
void on_sighup();
private:
void check_resize(bool force = false);
void redraw();