SCCS-vsn: lib/libcurses/tstp.c 5.8
-static char sccsid[] = "@(#)tstp.c 5.7 (Berkeley) %G%";
+static char sccsid[] = "@(#)tstp.c 5.8 (Berkeley) %G%";
#endif /* not lint */
#include <curses.h>
#endif /* not lint */
#include <curses.h>
- * tstp --
- * Handle stop and start signals.
+ * stop_signal_handler --
+ * Handle stop signals.
+__stop_signal_handler(signo)
int signo;
{
struct termios save;
int signo;
{
struct termios save;
/* Get the current terminal state. */
if (tcgetattr(STDIN_FILENO, &save))
return;
/* Get the current terminal state. */
if (tcgetattr(STDIN_FILENO, &save))
return;
- /* Move the cursor to the end of the screen. */
- mvcur(0, COLS - 1, LINES - 1, 0);
-
- /* End the window. */
+ /*
+ * Block every signal we can get our hands on. This is because
+ * applications have timers going off that want to repaint the
+ * screen.
+ */
+ (void)sigfillset(&set);
+ (void)sigprocmask(SIG_BLOCK, &set, &oset);
+
+ /*
+ * End the window, which also resets the terminal state to the
+ * original modes.
+ */
(void)sigemptyset(&set);
(void)sigaddset(&set, SIGTSTP);
(void)sigprocmask(SIG_UNBLOCK, &set, NULL);
(void)sigemptyset(&set);
(void)sigaddset(&set, SIGTSTP);
(void)sigprocmask(SIG_UNBLOCK, &set, NULL);
+
+ /* Stop ourselves. */
(void)signal(SIGTSTP, SIG_DFL);
(void)kill(0, SIGTSTP);
/* Time passes ... */
(void)signal(SIGTSTP, SIG_DFL);
(void)kill(0, SIGTSTP);
/* Time passes ... */
- /* Reset the signal handler. */
- (void)signal(SIGTSTP, tstp);
+ /* Reset the curses SIGTSTP signal handler. */
+ (void)signal(SIGTSTP, __stop_signal_handler);
- /* Reset the terminal state. */
+ /* Reset the terminal state its mode when we stopped. */
(void)tcsetattr(STDIN_FILENO, TCSADRAIN, &save);
/* Restart the screen. */
(void)tcsetattr(STDIN_FILENO, TCSADRAIN, &save);
/* Restart the screen. */
+ __startwin();
+
+ /* Repaint the screen. */
+
+ /* Reset the signals. */
+ (void)sigprocmask(SIG_SETMASK, &oset, NULL);