Re: signal(SIGFPE,SIG_IGN) causes endless loop

Albert Cahalan (albert@ccs.neu.edu)
Tue, 23 Apr 1996 14:46:16 -0400 (EDT)


/***** Divide by zero test ******/
#include <stdio.h>
#include <signal.h>
int ret_zero(){ /* fool SCO cc */
return 0;
}
int main(){
int a,b,c;
signal(SIGFPE,SIG_IGN);
a = 1;
b = ret_zero();
c = a/b;
return 0;
}
/********************************/

> OK, what about x86 OSs? This could affect iBCS a bit.

SCO OpenDesktop 1.1 (SCO Unix 3.2v2.0) Endless loop.
SCO OpenDesktop 2.0 (SCO Unix 3.2v4.0) Endless loop.
Digital Unix c == 0
SunOS (traditional) c == 0
Solaris 2.4 (SPARC) Floating exception, core
Solaris/x86 (SunOS 5.4 i386) sigerr, Arithmatic Exception, core
ULTRIX ultrix 4.4 0 RISC sigerr, trace trap, core
HP-UX 9.03 Endless loop (?)
SVR4 x86 (Siemens Nixdorf Sinix 5.41B) Endless loop
Dynix/ptx 4.0 and 4.1 Exits normally

__Action__Total__i386__
loop 4 3
coredump 3 1
0/x is 0 3 0

The table is not complete without FreeBSD, PosixWinNT,
and the Hurd, but I'd say that anything goes. Note that 2
of the OSs sent SIGERR instead of SIGFPE. I think letting
the process loop is taking the easy way out - a bug even.
I'd say dump core.

> Does it seem strange to anyone that an integer divison
> problem causes a floating point exception?

No kidding. I think I've seen SIGDIV0 somewhere.

None of this is _really_ bad. Some early CPUs would lock up.