Catching core dumps in a shell script

Michael Still mikal at stillhq.com
Mon Feb 4 18:15:07 EST 2002


On Mon, 4 Feb 2002, David Gibson wrote:

> On Mon, Feb 04, 2002 at 12:14:58PM +1100, Michael Still wrote:
> > My problem is that sometimes the parser core dumps, and these files then
> > don't get listed as having failed. Testing for the existance of a file
> > named core in the for loop doesn't seem to work... I am not sure why.
>
> A segfaulting program will return with non-zero status to the shell
> (139 to be specific).  It will count as "false" if run in a shell "if"
> statement.

Interesting... My code does something along the lines of (the laptop is
off, so I can't show you).

for pdffile in `blah`
do
  ./lexer < $pdffile > /dev/null
  if [ $? -gt 1 ]
  then
    echo "Bad thing"
  fi
done

But the if doesn't seem to happen for the core dumping examples. It's as
if the rest of the code in the loop is skipped if a core dump happened.

Where would I find a list of these reserved return codes?

Mikal

-- 

Michael Still (mikal at stillhq.com)     UMT+11hrs





More information about the linux mailing list