diff options
Diffstat (limited to 'lib/libncurses/lib_tstp.c')
-rw-r--r-- | lib/libncurses/lib_tstp.c | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/lib/libncurses/lib_tstp.c b/lib/libncurses/lib_tstp.c index 4412dcb..cb96ff0 100644 --- a/lib/libncurses/lib_tstp.c +++ b/lib/libncurses/lib_tstp.c @@ -20,10 +20,27 @@ void tstp(int dummy) { sigaction_t act, oact; -sigset_t mask; +sigset_t mask, omask; T(("tstp() called")); + /* + * The user may have changed the prog_mode tty bits, so save them. + */ + def_prog_mode(); + + /* + * Block window change and timer signals. The latter + * is because applications use timers to decide when + * to repaint the screen. + */ + (void)sigemptyset(&mask); + (void)sigaddset(&mask, SIGALRM); +#ifdef SIGWINCH + (void)sigaddset(&mask, SIGWINCH); +#endif + (void)sigprocmask(SIG_BLOCK, &mask, &omask); + endwin(); sigemptyset(&mask); @@ -41,10 +58,21 @@ sigset_t mask; T(("SIGCONT received")); sigaction(SIGTSTP, &oact, NULL); - reset_prog_mode(); flushinp(); - if (enter_ca_mode) - putp(enter_ca_mode); + + /* + * If the user modified the tty state while suspended, he wants + * those changes to stick. So save the new "default" terminal state. + */ + def_shell_mode(); + + /* + * This relies on the fact that doupdate() will restore the + * program-mode tty state, and issue enter_ca_mode if need be. + */ doupdate(); + + /* Reset the signals. */ + (void)sigprocmask(SIG_SETMASK, &omask, NULL); } |