[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Incorrect signal handling under SYSV machines
Hi,
> I have used es-0.9-alpha1 for many moon under SunOS 4.1.[34] and DEC
> Alpha UNIX V4.0. [Note: I always have `interrupt' set to Control C
> under the terminal driver.] Whenever I hit Control C, most normal
> programs interactively activated under the shell are killed and I get
> a fresh command prompt. If I was in the middle of forming a command
> line, it is killed and I get a fresh prompt. Even if I had typed
> nothing, I get a fresh prompt. [...]
>
> Under HP-UX 10.20, when I hit Control C twice at any points during a
> session under the es shell, the shell ``terminate[s] on signal 2.''
Hmm, yes...
I came across this a while ago, and I think the following fixed it for
me, pending further investigation (which is still pending 8^/ ):
*** signal.c.orig Tue May 30 12:13:51 1995
--- signal.c Fri Jul 7 10:36:44 1995
***************
*** 65,70 ****
--- 65,71 ----
/*
* the signal handler
*/
+ static Sighandler setsignal(int sig, Sighandler handler);
/* catcher -- catch (and defer) a signal from the kernel */
static void catcher(int sig) {
***************
*** 79,86 ****
++sigcount;
}
interrupted = TRUE;
! if (slow)
longjmp(slowlabel, 1);
}
--- 80,91 ----
++sigcount;
}
interrupted = TRUE;
! if (slow) {
! #if USE_SIGACTION
! setsignal(sig, catcher);
! #endif
longjmp(slowlabel, 1);
+ }
}
It looks like HP-UX is rather more strict, or something, about the
circumstances under which it restores the original signal mask in
a signal handler, using sigaction.
The HP-UX sigaction(2) manual entry says:
When a signal is caught by a signal-catching function installed
by sigaction, a new mask is calculated and installed for the
duration of the signal-catching function, or until a call is
made to sigprocmask() or sigsuspend() (see sigprocmask(2) and
sigsuspend(2)). [...] If and when the signal-catching function
returns normally, the original signal mask is restored.
The key is in that last sentence. When you press the INTR key during
command entry, the `slow' flag is true, and the code takes the longjmp
out of the signal handler. The longjmp doesn't count as `returning
normally' from the signal handler, so the signal mask isn't restored.
Hope this helps,
Chris
--
Chris R Dalton (crd@hplb.hpl.hp.com)
Hewlett-Packard Laboratories, Stoke Gifford, Bristol, UK BS12 6QZ
Phone: +44 117 922 8744 or +44 117 979 9910 x28744 FAX: +44 117 922 8924