Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: goto in CORE::GLOBAL::exit - is it safe?

by SFLEX (Chaplain)
on Aug 30, 2007 at 16:08 UTC ( #636127=note: print w/replies, xml ) Need Help??

in reply to goto in CORE::GLOBAL::exit - is it safe?

Ok, this code jumped out at me & it may help you out or it has nothing to pertain to the current title..
BEGIN { # Override with itself so it can be overridden at run-time later. *CORE::GLOBAL::exit = sub { CORE::exit @_; } } { my $exit_code; no warnings 'redefine'; local *CORE::GLOBAL::exit = sub { $exit_code = shift; goto EXIT; }; # code which calls abort handler... EXIT: $CGI::Fast::Ext_Request->Finish(); }

Replies are listed 'Best First'.
Re^2: goto in CORE::GLOBAL::exit - is it safe?
by powerman (Friar) on Aug 30, 2007 at 16:15 UTC
    Yeah, I've already seen this code here. ;-)

    I propose exactly same solution, and I just wonder why it was not used by mod_perl? This make me thinking there can be some hidden issues with this solution.

      thats the same link i got the code from.

      for mod_perl i use this code to exit. * Edited
      use subs qw(exit); # this is also part of the exit mod_perl code # if anyone cares # Figure out how to exit mod_perl. *exit = $ENV{'MOD_PERL'} ? \&Apache::exit : sub { CORE::exit };

      I was playing with another code like it but that one seemed to work better.
        ... and &Apache::exit internally call die(). And so it fail to "exit" if this code executed inside eval. This is documented issue, you can read about it here.

        I just wonder why not solve this issue by replacing die() with goto()?

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://636127]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2021-12-03 22:27 GMT
Find Nodes?
    Voting Booth?
    R or B?

    Results (30 votes). Check out past polls.