Mail Archives: djgpp/2000/10/27/14:13:04
> From: Jeffrey_Krupp AT May-Co DOT com
> Date: Fri, 27 Oct 2000 10:43:34 -0400
>
> void handler(int sig)
> {
> _clear87();
> _fpreset();
> printf("\nSignal!");
> fflush(stdout);
> getch();
> }
>
> void main(void)
> {
> int i;
>
> signal(SIGFPE,handler);
> i=1/0;
>
> printf("\nAfter division...still alive!");
> fflush(stdout);
> }
>
> This always enters the handler, but then kicks me out showing the
> registers.
You should always post the full crash message when you report crashes.
Don't let us guess if you want efficient help.
I'm guessing that the crash message started with this:
Cannot continue from exception, exiting due to signal SIGFPE
That's because your `main' is wrong: you cannot return from an
exception, because the exception will happen again, and the library
will abort your program to avoid the infinite exception chain. This
is explained in section 12.2 of the DJGPP FAQ list.
You need to change your code so that the signal handler longjmp's
instead of returning. Then it will work.
> But it doesn't call matherr().
matherr is not the right tool here: it is only called if a numerical
exception happens inside one of the library functions. In your case,
the exception is caused by a simple division, so matherr will not be
called.
- Raw text -