[Israel.pm] catching segmentation faults and other crashes

Mikhael Goikhman migo at homemail.com
Mon Nov 12 04:26:29 PST 2007


On 12 Nov 2007 14:14:28 +0200, Yona Shlomo wrote:
> 
> On Mon, 12 Nov 2007, Mikhael Goikhman wrote:
> 
> > Of course, if Shlomo just wanted to detect abnormal exit and not "core
> > dump", then checking for non-zero $? should be portable enough.
> 
> Yes. This is my fallback -- but can't I get false positives this wat?

If your program does exit(0) on success, then just check for non-zero $?
to catch a failure. If the program may exit with something else and you
don't want to consider it a failure, check for non-zero "$? & 127" to
catch abnormal exit (like "kill -9" or other signal or "Out of memory").
This should be portable enough.

Regards,
Mikhael.

-- 
perl -e 'print+chr(64+hex)for+split//,d9b815c07f9b8d1e'



More information about the Perl mailing list