summaryrefslogtreecommitdiff
path: root/lib/libcurses/tty
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1999-01-31 20:17:11 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1999-01-31 20:17:11 +0000
commitfb70e89dae9574330a73792f0fceddfab62202b9 (patch)
tree18b545328dd6256be0c7c1201cf94a31446e9d16 /lib/libcurses/tty
parent3b9b932e9a8c5afd5438f8d93bf20a7f032d8847 (diff)
ncurses-4.2-990130
Diffstat (limited to 'lib/libcurses/tty')
-rw-r--r--lib/libcurses/tty/lib_tstp.c36
-rw-r--r--lib/libcurses/tty/tty_update.c35
2 files changed, 41 insertions, 30 deletions
diff --git a/lib/libcurses/tty/lib_tstp.c b/lib/libcurses/tty/lib_tstp.c
index 709b7ce492a..11455deff2c 100644
--- a/lib/libcurses/tty/lib_tstp.c
+++ b/lib/libcurses/tty/lib_tstp.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_tstp.c,v 1.1 1999/01/18 19:10:26 millert Exp $ */
+/* $OpenBSD: lib_tstp.c,v 1.2 1999/01/31 20:17:10 millert Exp $ */
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,1999 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -50,7 +50,7 @@
#define _POSIX_SOURCE
#endif
-MODULE_ID("$From: lib_tstp.c,v 1.15 1998/02/11 12:13:57 tom Exp $")
+MODULE_ID("$From: lib_tstp.c,v 1.17 1999/01/31 01:06:14 tom Exp $")
/*
* Note: This code is fragile! Its problem is that different OSs
@@ -101,12 +101,25 @@ static void tstp(int dummy GCC_UNUSED)
sigset_t mask, omask;
sigaction_t act, oact;
+#ifdef SIGTTOU
+ int sigttou_blocked;
+#endif
+
T(("tstp() called"));
/*
* The user may have changed the prog_mode tty bits, so save them.
+ *
+ * But first try to detect whether we still are in the foreground
+ * process group - if not, an interactive shell may already have
+ * taken ownership of the tty and modified the settings when our
+ * parent was stopped before us, and we would likely pick up the
+ * settings already modified by the shell.
*/
- def_prog_mode();
+#if HAVE_TCGETPGRP
+ if (tcgetpgrp(STDIN_FILENO) == getpgrp())
+#endif
+ def_prog_mode();
/*
* Block window change and timer signals. The latter
@@ -120,6 +133,15 @@ static void tstp(int dummy GCC_UNUSED)
#endif
(void)sigprocmask(SIG_BLOCK, &mask, &omask);
+#ifdef SIGTTOU
+ sigttou_blocked = sigismember(&omask, SIGTTOU);
+ if (!sigttou_blocked) {
+ (void)sigemptyset(&mask);
+ (void)sigaddset(&mask, SIGTTOU);
+ (void)sigprocmask(SIG_BLOCK, &mask, NULL);
+ }
+#endif
+
/*
* End window mode, which also resets the terminal state to the
* original (pre-curses) modes.
@@ -129,6 +151,12 @@ static void tstp(int dummy GCC_UNUSED)
/* Unblock SIGTSTP. */
(void)sigemptyset(&mask);
(void)sigaddset(&mask, SIGTSTP);
+#ifdef SIGTTOU
+ if (!sigttou_blocked) {
+ /* Unblock this too if it wasn't blocked on entry */
+ (void)sigaddset(&mask, SIGTTOU);
+ }
+#endif
(void)sigprocmask(SIG_UNBLOCK, &mask, NULL);
/* Now we want to resend SIGSTP to this process and suspend it */
diff --git a/lib/libcurses/tty/tty_update.c b/lib/libcurses/tty/tty_update.c
index 9fd81963b5e..503b63c654d 100644
--- a/lib/libcurses/tty/tty_update.c
+++ b/lib/libcurses/tty/tty_update.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty_update.c,v 1.1 1999/01/18 19:10:27 millert Exp $ */
+/* $OpenBSD: tty_update.c,v 1.2 1999/01/31 20:17:10 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998 Free Software Foundation, Inc. *
@@ -77,7 +77,7 @@
#include <term.h>
-MODULE_ID("$From: tty_update.c,v 1.109 1998/10/03 19:08:33 tom Exp $")
+MODULE_ID("$From: tty_update.c,v 1.110 1999/01/31 01:45:37 Alexander.V.Lukyanov Exp $")
/*
* This define controls the line-breakout optimization. Every once in a
@@ -101,7 +101,7 @@ static inline chtype ClrBlank ( WINDOW *win );
static int ClrBottom(int total);
static int InsStr( chtype *line, int count );
static void ClearScreen( chtype blank );
-static void ClrUpdate( WINDOW *win );
+static void ClrUpdate( void );
static void DelChar( int count );
static void TransformLine( int const lineno );
@@ -682,19 +682,11 @@ struct tms before, after;
#endif /* USE_XMC_SUPPORT */
nonempty = 0;
- if (curscr->_clear) { /* force refresh ? */
- /* yes, clear all & update */
- T(("clearing and updating curscr"));
- if (is_wintouched(newscr))
- ClrUpdate(newscr);
- else
- ClrUpdate(curscr);
+ if (curscr->_clear || newscr->_clear) { /* force refresh ? */
+ T(("clearing and updating from scratch"));
+ ClrUpdate();
curscr->_clear = FALSE; /* reset flag */
newscr->_clear = FALSE; /* reset flag */
- } else if (newscr->_clear) {
- T(("clearing and updating newscr"));
- ClrUpdate(newscr);
- newscr->_clear = FALSE;
} else {
int changedlines = CHECK_INTERVAL;
@@ -802,29 +794,20 @@ chtype blank = BLANK;
}
/*
-** ClrUpdate(win)
+** ClrUpdate()
**
** Update by clearing and redrawing the entire screen.
**
*/
-static void ClrUpdate(WINDOW *win)
+static void ClrUpdate(void)
{
int i;
- chtype blank = ClrBlank(win);
+ chtype blank = ClrBlank(stdscr);
int nonempty = min(screen_lines, newscr->_maxy+1);
T(("ClrUpdate() called"));
- if (win == curscr) {
- /* discard updates */
- for (i = 0; i < screen_lines ; i++) {
- memcpy( newscr->_line[i].text,
- curscr->_line[i].text,
- screen_columns * sizeof(chtype));
- }
- }
-
ClearScreen(blank);
T(("updating screen from scratch"));