[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
lynx-dev Suggested patch for "^Z from editor" problem
From: |
Klaus Weide |
Subject: |
lynx-dev Suggested patch for "^Z from editor" problem |
Date: |
Mon, 12 Jul 1999 18:31:39 -0500 (CDT) |
Here is what I have to eliminate the strange behavior.
Note that I haven't tested at all whether it has the effect
it's supposed to have (my latest compiles are with slang, not
enough space/time to do an ncurses version now).
Could those who have reproduced the problem please try this.
(Only one file affected, no need to recompile whole source tree
in this case.)
Note that this requires compiling LYUtils.c with -DHAVE_SIGACTION
(and, of course, *actually having* sigaction()...),
I didn't bother to do a signal()-only version.
I use
make SITE_DEFS="-DHAVE_SIGACTION"
for this.
Klaus
Index: lynx2-8-3/src/LYUtils.c
--- orig/lynx2-8-3/src/LYUtils.c Mon, 28 Jun 1999 19:46:36 -0500
+++ lynx2-8-3/src/LYUtils.c Mon, 12 Jul 1999 18:20:32 -0500
@@ -3101,6 +3101,53 @@
}
#endif /* HAVE_SIGACTION */
+#if defined(SIGTSTP) && !defined(USE_SLANG)
+#if HAVE_SIGACTION
+/*
+ * For switching a signal's handling between SIG_DFL and something
+ * (possibly) different that may have been set up by lynx code or
+ * e.g. by curses library. Uses sigaction to preserve / restore as
+ * much state as possible.
+ * Second arg is where to save or restore from.
+ * Third arg to_dfl specifies what to do:
+ * 1 Save current state in where, set handling to SIG_DFL
+ * 0 Restore current state to previously saved one in where
+ *
+ * Currently only used for SIGTSTP without SLANG, to prevent (n)curses
+ * signal handler from running while lynx is waiting in system() for
+ * an interactive command like an editor. - kw
+ */
+PRIVATE BOOLEAN LYToggleSigDfl ARGS3(
+ int, sig,
+ struct sigaction *, where,
+ int, to_dfl)
+{
+ int rv = -1;
+ struct sigaction oact;
+
+ if (to_dfl == 1) {
+ rv = sigaction(sig, NULL, &oact);
+ if (rv == 0) {
+ if (oact.sa_handler != SIG_DFL) {
+ oact.sa_handler = SIG_DFL;
+ rv = sigaction(sig, &oact, where);
+ } else if (where) {
+ memcpy(where, &oact, sizeof(oact));
+ rv = 0;
+ }
+ }
+ } else {
+ rv = sigaction(sig, where, NULL);
+ }
+ if (rv != 0) {
+ CTRACE(tfp, "Error in LYToggleSigDfl: %s\n", LYStrerror(errno));
+ return FALSE;
+ } else
+ return TRUE;
+}
+#endif /* HAVE_SIGACTION */
+#endif /* SIGTSTP && !USE_SLANG */
+
/**************
** This bit of code catches window size change signals
**/
@@ -6789,6 +6836,11 @@
{
int code;
int do_free = 0;
+#if HAVE_SIGACTION && defined(SIGTSTP) && !defined(USE_SLANG)
+ struct sigaction saved_sigtstp_act;
+ BOOLEAN sigtstp_saved = FALSE;
+#endif
+ int saved_errno = 0;
fflush(stdout);
fflush(stderr);
@@ -6828,7 +6880,16 @@
# endif
if (restore_sigpipe_for_children)
signal(SIGPIPE, SIG_DFL); /* Some commands expect the default */
+#if HAVE_SIGACTION && defined(SIGTSTP) && !defined(USE_SLANG)
+ if (!dump_output_immediately && !LYCursesON && !no_suspend)
+ sigtstp_saved = LYToggleSigDfl(SIGTSTP, &saved_sigtstp_act, 1);
+#endif
code = system(command);
+ saved_errno = errno;
+#if HAVE_SIGACTION && defined(SIGTSTP) && !defined(USE_SLANG)
+ if (sigtstp_saved)
+ LYToggleSigDfl(SIGTSTP, &saved_sigtstp_act, 0);
+#endif
if (restore_sigpipe_for_children)
signal(SIGPIPE, SIG_IGN); /* Ignore it again - kw */
#endif
@@ -6843,6 +6904,9 @@
if (do_free)
FREE(command);
+#if !defined(UCX) || !defined(VAXC) /* errno not modifiable ?? */
+ errno = saved_errno; /* may have been clobbered */
+#endif
return code;
}
- lynx-dev Suggested patch for "^Z from editor" problem,
Klaus Weide <=
- Re: lynx-dev Suggested patch for "^Z from editor" problem, Larry W. Virden, 1999/07/12
- Re: lynx-dev Suggested patch for "^Z from editor" problem, T.E.Dickey, 1999/07/12
- Re: lynx-dev Suggested patch for "^Z from editor" problem, Larry W. Virden, 1999/07/12
- Re: lynx-dev Suggested patch for "^Z from editor" problem, T.E.Dickey, 1999/07/12
- Re: lynx-dev Suggested patch for "^Z from editor" problem, T.E.Dickey, 1999/07/13