delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/10/27/14:13:04

Date: Fri, 27 Oct 2000 20:12:39 +0200
From: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>
Sender: halo1 AT zahav DOT net DOT il
To: Jeffrey_Krupp AT May-Co DOT com
Message-Id: <9003-Fri27Oct2000201239+0200-eliz@is.elta.co.il>
X-Mailer: Emacs 20.6 (via feedmail 8.3.emacs20_6 I) and Blat ver 1.8.5h
CC: djgpp AT delorie DOT com
In-reply-to: <OFB44903C9.92C2A467-ON85256985.004F4061@COM>
(Jeffrey_Krupp AT May-Co DOT com)
Subject: Re: Division by zero : SIGFPE
References: <OFB44903C9 DOT 92C2A467-ON85256985 DOT 004F4061 AT COM>
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> 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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019