[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
lynx-dev Problem with ^Z suspending: ncurses lib_tstp.pch
From: |
Klaus Weide |
Subject: |
lynx-dev Problem with ^Z suspending: ncurses lib_tstp.pch |
Date: |
Wed, 27 Jan 1999 12:26:27 -0600 (CST) |
I made the following changes to some ncurses sources I had lying
around. Sorry it's not the latest version, didn't want to download
the whole thing, this was version 4.0.
This works for me to solve problems I and III (see my other message,
http://www.flora.org/lynx-dev/html/month0199/msg00737.html).
Tom, can you look at this for including in ncurses? I'm sure it needs
at least some ifdefs.
Klaus
--- lib_tstp.c.old Wed Jan 27 10:52:15 1999
+++ lib_tstp.c Wed Jan 27 11:46:16 1999
@@ -95,13 +95,23 @@
{
sigset_t mask, omask;
sigaction_t act, oact;
+
+ int tty_stolen, sigttou_blocked;
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();
+ tty_stolen = (tcgetpgrp(STDIN_FILENO) != getpgrp());
+ if (!tty_stolen)
+ def_prog_mode();
/*
* Block window change and timer signals. The latter
@@ -115,6 +125,15 @@
#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.
@@ -124,6 +143,12 @@
/* 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 */
- lynx-dev Problem with ^Z suspending: ncurses lib_tstp.pch,
Klaus Weide <=