Re: signal(SIGFPE,SIG_IGN) causes endless loop

Ulrich Klein (ulik@hprc.tandem.com)
Wed, 24 Apr 1996 13:33:32 +0200


> On Mon, 22 Apr 1996, Albert Cahalan wrote:
>
> > >>> #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;
> > >>> }
> > >>
> > >> In case anyone cares, this program runs to completion under
> > >> both Digital Unix and SunOS. The result of c after the
> > >> division is 0 on both platforms.
> > >
> > > It dumps core on Solaris 2.4 with the message:
> > > Floating exception (core dumped).
> >
> > OK, what about x86 OSs? This could affect iBCS a bit.
> >
> > FreeBSD:
> > Unixware:
2.03: Compiled with -O just runs without giving any error
This is somehow correct, because the whole program is optimized to nothing
(a, b, c set but never used). Adding a printf or compiling without -O
generates the code for the division, lets the program run forever not
responding to CTL-C, must kill it.

Uli

--
==================================================================
Ulrich Klein
Tandem Inc. HPRC                  Phone: +49-6172-7369-52
Max-Planck-Str. 36                FAX  : +49-6172-74655
D-61381 Friedrichsdorf            Email: ulik@suse.hprc.tandem.com
==================================================================