summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2019-09-24 23:28:11 +1000
committerMaxime Coste <mawww@kakoune.org>2019-09-24 23:28:11 +1000
commitde3ff78b22a37f628f5208668f9aed02a7de6606 (patch)
treeacbf39b62cbcf6908b38ef552e38026580f3d7cf /src
parentf066014d33c02460c4dcabaa03385b345a1bf934 (diff)
Restore stdin status flags on suspend and quit
Those flags are shared with the parent process, so the non-block flag added impacts their execution.
Diffstat (limited to 'src')
-rw-r--r--src/ncurses_ui.cc6
-rw-r--r--src/ncurses_ui.hh1
2 files changed, 6 insertions, 1 deletions
diff --git a/src/ncurses_ui.cc b/src/ncurses_ui.cc
index 8f9dac98..13859088 100644
--- a/src/ncurses_ui.cc
+++ b/src/ncurses_ui.cc
@@ -361,6 +361,7 @@ NCursesUI::NCursesUI()
}},
m_assistant(assistant_clippy)
{
+ m_original_stdin_flags = fcntl(STDIN_FILENO, F_GETFL, 0);
tcgetattr(STDIN_FILENO, &m_original_termios);
initscr();
@@ -385,6 +386,7 @@ NCursesUI::~NCursesUI()
m_palette.set_change_colors(false);
endwin();
tcsetattr(STDIN_FILENO, TCSAFLUSH, &m_original_termios);
+ fcntl(STDIN_FILENO, F_SETFL, m_original_stdin_flags);
set_signal_handler(SIGWINCH, SIG_DFL);
set_signal_handler(SIGCONT, SIG_DFL);
set_signal_handler(SIGTSTP, SIG_DFL);
@@ -404,9 +406,11 @@ void NCursesUI::suspend()
sigaddset(&unblock_sigtstp, SIGTSTP);
sigprocmask(SIG_UNBLOCK, &unblock_sigtstp, &old_mask);
tcsetattr(STDIN_FILENO, TCSAFLUSH, &m_original_termios);
+ fcntl(STDIN_FILENO, F_SETFL, m_original_stdin_flags);
raise(SIGTSTP); // suspend here
+ m_original_stdin_flags = fcntl(STDIN_FILENO, F_GETFL, 0);
tcsetattr(STDIN_FILENO, TCSAFLUSH, &m_original_termios);
set_signal_handler(SIGTSTP, current);
sigprocmask(SIG_SETMASK, &old_mask, nullptr);
@@ -420,7 +424,7 @@ void NCursesUI::suspend()
void NCursesUI::set_raw_mode() const
{
- fcntl(STDIN_FILENO, F_SETFL, fcntl(STDIN_FILENO, F_GETFL, 0) | O_NONBLOCK);
+ fcntl(STDIN_FILENO, F_SETFL, m_original_stdin_flags | O_NONBLOCK);
termios attr = m_original_termios;
attr.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON);
diff --git a/src/ncurses_ui.hh b/src/ncurses_ui.hh
index 3a7b406a..296d6ca3 100644
--- a/src/ncurses_ui.hh
+++ b/src/ncurses_ui.hh
@@ -121,6 +121,7 @@ private:
DisplayCoord m_dimensions;
termios m_original_termios{};
+ int m_original_stdin_flags;
void set_raw_mode() const;