Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: die silently in an eval block while using alarm

by andal (Friar)
on Feb 22, 2013 at 07:49 UTC ( #1020097=note: print w/ replies, xml ) Need Help??


in reply to die silently in an eval block while using alarm

I can't really see, how "die" in your code could produce any output. It is called by ALRM signal handler inside of eval, so the output of "die" is saved in $@ and not printed anywhere. If you get some output, then it comes from somewhere else. Check for example this code

my $ch; eval{ $SIG{ALRM} = sub{ die "Waiting finished\n"; }; alarm(10); $ch = <STDIN>; alarm(0); }; if($@) { print "Timeout happened\n"; } else { print "Got $ch"; }
You'll never see "Waiting finished" because it is stored in $@ variable and the code does not print it.


Comment on Re: die silently in an eval block while using alarm
Download Code
Re^2: die silently in an eval block while using alarm
by gg48gg (Sexton) on Feb 22, 2013 at 21:55 UTC
    Thanks for the reply. I agree, I shouldn't have any output from die. Is it possible that I get output from the result of die? I can't explain the behavior, I can just observe it. Thanks for the example code, I will study it for a bit.

      What do you mean by "result of die"? "die" never returns, so there is no "result" returned.

      Search for the problem somewhere else. It has nothing to do with "die" in provided piece of code. Inside of eval "die" does not produce any output. Check your other "warn", "print", "write", or "die" outside of eval.

Log In?
Username:
Password:

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

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

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (206 votes), past polls