summaryrefslogtreecommitdiffstats
path: root/lib/libncurses/lib_tstp.c
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1997-08-25 07:41:15 +0000
committerache <ache@FreeBSD.org>1997-08-25 07:41:15 +0000
commit55ba1a93b942a8056a8829883d191508e4a69dd6 (patch)
tree4cf8660ed14428df6fd32c7453a3283f2b26d63a /lib/libncurses/lib_tstp.c
parente779aaeea32924e0708694dde350540711b5f05e (diff)
downloadFreeBSD-src-55ba1a93b942a8056a8829883d191508e4a69dd6.zip
FreeBSD-src-55ba1a93b942a8056a8829883d191508e4a69dd6.tar.gz
Fix saving/restoring tty modes, allow initscr be called twice,
from ncurses 4.1
Diffstat (limited to 'lib/libncurses/lib_tstp.c')
-rw-r--r--lib/libncurses/lib_tstp.c36
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);
}
OpenPOWER on IntegriCloud