delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/03/02/11:10:19

Date: Thu, 2 Mar 2000 11:31:27 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Marcus <mesthlm AT hem DOT passagen DOT se>
cc: djgpp AT delorie DOT com
Subject: Re: Prevent crash on free()
In-Reply-To: <89j9h7$fbp$2@zingo.tninet.se>
Message-ID: <Pine.SUN.3.91.1000302113106.24728R-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: dj-admin AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Wed, 1 Mar 2000, Marcus wrote:

> "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il> wrote:
> > You can install a handler for the signal SIGSEGV.  If that handler
> > longjmp's, then it will indeed work.  But if it returns to the same
> > place where the problem happened, the progarm will still crash.
> 
> A nice function. Thank you...
> Can I catch all types of crashes with one call?

A single call like this:

  signal (SIGSEGV, my_crash_handler);

will cause my_crash_handler to be called for all crashes that result
in a SIGSEGV.  If you want to catch other kinds of trouble, like
SIGFPE (e.g., divide by zero) or SIGILL, you need additional calls:

  signal (SIGFPE, my_crash_handler);
  signal (SIGILL, my_crash_handler);

You handler gets passed the actual signal when it is invoked, so you
could give an appropriate handling to each one of the different
signals in the same function.

- Raw text -


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