darren chamberlain <[EMAIL PROTECTED]> writes:

> Try localizing the reassignment to the suspected problem area, or just
> set $Apache::Registry::Debug to a false value.  confessing would
> definitely be useful in other places.
> 
>   sub handler {
>       local $SIG{__DIE__};
>       # ... and so on


Yes. Thank you!

(I should have known this.. :)

The section for die talks about the $SIG{__DIE__} callback:

    Because this promotes strange action at a distance, this
    counterintuitive behavior may be fixed in a future release.

(Regarding it being called from inside an eval.)


And I found the source of the error in diagnostics.pm:

    # We don't want to unset these if we're coming from an eval because
    # then we've turned off diagnostics. (Actually what does this next
    # line do?  -PSeibel)
    $SIG{__DIE__} = $SIG{__WARN__} = '' unless $in_eval;
    local($Carp::CarpLevel) = 1;
    confess "Uncaught exception from user code:\n\t$exception";
        # up we go; where we stop, nobody knows, but i think we die now
        # but i'm deeply afraid of the &$olddie guy reraising and us getting
        # into an indirect recursion loop


That's right.  I fond that I had a "use diagnostics" in a (very) old
Apach::Registry program, and that thing changes the hooks globaly.

    $SIG{__WARN__} = \&warn_trap;
    $SIG{__DIE__} = \&death_trap;

If I wanted diagnostics in mod_perl, I should have put a
   disable diagnostics;

... at the end.






ABOUT UNSETTING DIE CALLBACK


I wonder about how to set the hook to default.  The perlvar manpage says:

                   $SIG{'INT'}  = 'DEFAULT';   # restore default action

I used that for __WARN__ and __DIE__ but that diagnostics module complained:

INTERNAL EXCEPTION: Can't use string ("DEFAULT") as a subroutine ref while "strict 
refs" in use at /usr/share/perl/5.6.1/diagnostics.pm line 444.
[Wed May  8 00:12:12 2002] [error] Can't use string ("DEFAULT") as a subroutine ref 
while "strict refs" in use at /usr/share/perl/5.6.1/diagnostics.pm line 464


Looking at source code, I have seen other variants:

    local $SIG{__DIE__} = '';         # Is this a way go back to default?


    local $SIG{__DIE__} = sub {};     # This would be the same as 'IGNORE'?
 

You suggested just saying
    local $SIG{__DIE__};

... That would make the callback undef.  Is that the same thing as DEFULT?

-- 
/ Jonas  -  http://jonas.liljegren.org/myself/en/index.html


Reply via email to