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

I don't know why you're getting zero — you should never get zero from die — but your code is broken since Log and CloseLog probably change $!.

Replies are listed 'Best First'.
Re^4: bad die behaviour?
by Anonymous Monk on Sep 10, 2007 at 13:13 UTC
    I also don't know why it returns 0. I have tried to force
    $! = 1;
    just before the die and the script ends with return code 0 to the shell.
    The functions Log and CloseLog are very simple. They write a formatted log line and close the log file.

    thanks
    Xavi

      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.

        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