[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
lynx-dev strange HTTP/HTCheckForInterrupt() bug - another patch
From: |
Klaus Weide |
Subject: |
lynx-dev strange HTTP/HTCheckForInterrupt() bug - another patch |
Date: |
Mon, 19 Apr 1999 07:30:03 -0500 (CDT) |
On Mon, 19 Apr 1999, Leonid Pauzner wrote:
> 18-Apr-99 01:24 Leonid Pauzner wrote:
> > 29-Mar-99 16:50 Bela Lubkin wrote:
>
> >> But I don't think that's what Leonid was running into. That's something
> >> else, possibly the need to signal((various signals), quench) *before*
> >> fork().
Try this. Untested, since I didn't get the abnormal exit frequentely.
Disadvantage: requires sigprocmask(), so far we have always avoided
using anything more than just 'signal()'. For now needs explicit
-DHAVE_SIGPROCMASK.
Klaus
--- lynx2-8-2.old/WWW/Library/Implementation/HTTCP.c Tue Apr 13 04:39:16 1999
+++ lynx2-8-2/WWW/Library/Implementation/HTTCP.c Mon Apr 19 07:06:17 1999
@@ -686,6 +686,10 @@
lynx_nsl_status = HT_INTERNAL; /* should be set to something else
below */
+#ifdef DEBUG_HOSTENT_CHILD
+ CTRACE_FLUSH(tfp);
+#endif
+
#ifdef NSL_FORK
statuses.h_errno_valid = NO;
/*
@@ -694,6 +698,10 @@
*/
{
int got_rehostent = 0;
+#ifdef HAVE_SIGPROCMASK
+ sigset_t old_sigset;
+ sigset_t new_sigset;
+#endif
/*
** Pipe, child pid, status buffers, start time, select()
** control variables.
@@ -722,6 +730,31 @@
pipe(pfd);
+#ifdef HAVE_SIGPROCMASK
+ /*
+ * Attempt to prevent a rare situation where the child
+ * could execute the Lynx signal handlers because it gets
+ * killed before it even has a chance to reset its handlers.
+ * - kw
+ */
+ sigemptyset(&new_sigset);
+ sigaddset(&new_sigset, SIGTERM);
+ sigaddset(&new_sigset, SIGINT);
+#ifndef NOSIGHUP
+ sigaddset(&new_sigset, SIGHUP);
+#endif /* NOSIGHUP */
+#ifdef SIGTSTP
+ sigaddset(&new_sigset, SIGTSTP);
+#endif /* SIGTSTP */
+#ifdef SIGWINCH
+ sigaddset(&new_sigset, SIGWINCH);
+#endif /* SIGWINCH */
+ sigaddset(&new_sigset, SIGBUS);
+ sigaddset(&new_sigset, SIGSEGV);
+ sigaddset(&new_sigset, SIGILL);
+ sigprocmask(SIG_BLOCK, &new_sigset, &old_sigset);
+#endif /* HAVE_SIGPROCMASK */
+
if ((fpid = fork()) == 0 ) {
struct hostent *phost; /* Pointer to host - See netdb.h */
/*
@@ -759,6 +792,11 @@
signal(SIGSEGV, SIG_DFL);
signal(SIGILL, SIG_DFL);
+#ifdef HAVE_SIGPROCMASK
+ /* Restore signal mask to whatever it was before the fork. -kw */
+ sigprocmask(SIG_SETMASK, &old_sigset, NULL);
+#endif /* HAVE_SIGPROCMASK */
+
/*
** Child won't use read side. -BL
*/
@@ -809,6 +847,14 @@
_exit(1);
}
}
+
+#ifdef HAVE_SIGPROCMASK
+ /*
+ ** (parent) Restore signal mask to whatever it was
+ ** before the fork. - kw
+ */
+ sigprocmask(SIG_SETMASK, &old_sigset, NULL);
+#endif /* HAVE_SIGPROCMASK */
/*
** (parent) Wait until lookup finishes, or interrupt,