Date: Thu, 2 Mar 2000 11:31:27 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: Marcus cc: djgpp AT delorie DOT com Subject: Re: Prevent crash on free() In-Reply-To: <89j9h7$fbp$2@zingo.tninet.se> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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 Precedence: bulk On Wed, 1 Mar 2000, Marcus wrote: > "Eli Zaretskii" 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.