Re: signal(SIGFPE,SIG_IGN) causes endless loop

Bryn Paul Arnold Jones (bpaj@gytha.demon.co.uk)
Sat, 20 Apr 1996 13:31:51 +0100 (BST)


On Sat, 20 Apr 1996, Linus Torvalds wrote:

> On Sat, 20 Apr 1996, Bryn Paul Arnold Jones wrote:
> >
> > On 19 Apr 1996, Thomas Koenig wrote:
> >
> > > The following program loops endlessly, with repeated SIGFPE's, as
> > > repeated by strace.
> > >
> > > This is an old, old bug, but maybe fixable before 2.0?
> > >
> > > #include <stdio.h>
> > > #include <signal.h>
> > >
> > > int main()
> > > {
> > > int a,b,c;
> > >
> > > signal(SIGFPE,SIG_IGN);
> > > a = 1;
> > > b = 0;
> > > c = a/b;
> > > return 0;
> > > }
> > >
> > Hmm, gdb sais it's restarting on line 11 (c=a/b), after the signal.
> > Perhaps it should ignore the signal, and carry on on the next line ....
> > (you know what I mean).
>
> Can't be done, at least not without doing something overly complex (like
> disassembling the faulting instruction and jumping over it "by hand" in
> the kernel).
>
> The thing that sends SIGFPE might check if SIGFPE is ignored/blocked, and
> just kill the process forcibly if so (same for SIGSEGV etc, I guess).
> That process _deserves_ to die ("My name is Linus Torvalds, prepare to
> die").
>
> Linus
>
Surely even if we're ignoreing the signal, it should allow the program to
carry on as if we haden't reseved the signal, in this case, this happens:

...
set variables
attempt to divide by 0
ignore SIGFIE
attempt to divide by 0
ignore SIGFIE
attempt to divide by 0
ignore SIGFIE
attempt to divide by 0
ignore SIGFIE
attempt to divide by 0
ignore SIGFIE
attempt to divide by 0
ignore SIGFIE
...

Now if dosen't that seem broken to you, or does the signal still have an
effect on us ? ie to me, if I'm ignoring something, I want it to be as
though it never happened.
Bryn

--
PGP key pass phrase forgotten,   \ Overload -- core meltdown sequence 
again :(                          |            initiated.
                                 / This space is intentionally left   
                                |  blank, apart from this text ;-)
                                 \____________________________________