in reply to Re^4: bad die behaviour?
in thread bad die behaviour?

Do you have a $SIG{__DIE__} handler that calls exit?

They write a formatted log line and close the log file.

Both of which can change $!. It's unrelated to the problem you asked about, but a bug nonetheless.

Replies are listed 'Best First'.
Re^6: bad die behaviour?
by Anonymous Monk on Sep 10, 2007 at 13:38 UTC
    No I don't have any signal handler defined. I also tried to print the whole %SIG hash just before the die, to see if any module had set any signal handler that I wasn't aware of, and the only signal handler active was the floating point exception handler.
    thanks
    Xavi
      You might want to consider using $SIG{__DIE__} instead of the FatalError subroutine. Put what you are doing in the FatalError into the subroutine for the DIE signal handler, evaluate $? (instead of $!) before die'ing.

      Something like:

      $SIG{__DIE__}=sub{ print STDERR "I'm Dyin!: \n"; }; some_command; $error_code=$?>>8; print "Finished running some_command"; die if $error_code > 0;