Re: signal(SIGFPE,SIG_IGN) causes endless loop

Stephen.Rothwell@nec.com.au
Tue, 23 Apr 1996 16:05:25 +1000


Albert Cahalan <albert@ccs.neu.edu> writes:
> >>> #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;
> >>> }
>
> OK, what about x86 OSs? This could affect iBCS a bit.
>
> SCO Unix:

Well on SCO the proram above does not compile! The compiler notices the
divide by zero :-)

The following program compiles:

#include <stdio.h>
#include <signal.h>

int ret_zero()
{
return 0;
}

int main()
{
int a,b,c;

signal(SIGFPE,SIG_IGN);
a = 1;
b = ret_zero();
c = a/b;
return 0;
}

when executed, it loops just like Linux!

This is Open Desktop 1.1 (SCO Unix 3.2v2.0).
Same on OpenDesktop 2.0 (SCO Unix 3.2v4.0).

Cheers,
Stephen

--
Stephen Rothwell                    Stephen.Rothwell@nec.com.au
NEC Australia                       Phone: +61-6-2508747
Information Systems Group           Fax:   +61-6-2508746
Canberra, Australia