Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^3: Program unexpectedly terminates

by ColonelPanic (Friar)
on Nov 19, 2012 at 09:09 UTC ( #1004491=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Program unexpectedly terminates
in thread Program unexpectedly terminates

Thanks for the additional information. I didn't understand that you were trying to trap explicit calls to exit(). That makes sense, then.

Playing around more with the BEGIN block, I found that an exit() statement within another package was only overridden if the BEGIN block came before the package definition. Do you have this block before you include all of your modules?

Also, would Test::Trap be helpful?



When's the last time you used duct tape on a duct? --Larry Wall


Comment on Re^3: Program unexpectedly terminates
Re^4: Program unexpectedly terminates
by Anonymous Monk on Nov 19, 2012 at 09:20 UTC
    Yes, the code in the main package is exactly what I'm using- only the Crawler package is abreviated. Test::Trap is basically an eval and only traps &CORE::GLOBAL::exit, so I don't think it does anything else than what I've tried.

      Well, your code should be catching any normal exit case. You still won't be catching exit() within an eval block, but your END statement should happen nonetheless.

      I don't see any way forward other than basic debugging in order to narrow down where, exactly, this problem occurs.



      When's the last time you used duct tape on a duct? --Larry Wall

        There's another case not covered: exec. Something like exec("/bin/true") will effectively exit a script without triggering any END blocks, etc.

        Illustration:

        #!/usr/bin/env perl use 5.010; use strict; use warnings; BEGIN { *CORE::GLOBAL::exit = sub { die("exit called") } } END { say "END block"; } do { exec "/bin/true" }; # Assuming a Unix-like system here say "got here";
        perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (14)
As of 2014-07-31 19:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (251 votes), past polls