Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

trapping signals

by opensourcer (Monk)
on Nov 23, 2006 at 16:30 UTC ( #585744=perlquestion: print w/ replies, xml ) Need Help??
opensourcer has asked for the wisdom of the Perl Monks concerning the following question:

hi, im trying to trap signals. but i don't want the program to quit. i want it to stay alive.
package Server; use Guard; sub new { my ($caller, %args) = @_; my $this = $caller || ref($caller) die; return bless[], $this; } 1;
now Guard
package Guard; $SIG{__DIE__} = \&diewatcher; $SIG{'QUIT'} = \&diewatcher; sub diewatcher { $SIG{__DIE__} = 'DEFAULT'; print "Na na u can't that \n"; } 1;
k, the above code does the work, but it does not stay alive.

Comment on trapping signals
Select or Download Code
Re: trapping signals
by Joost (Canon) on Nov 23, 2006 at 16:43 UTC
Re: trapping signals
by geekphilosopher (Friar) on Nov 24, 2006 at 00:27 UTC
    Quoth the Camel:
    When a __DIE__ hook routine returns, exception processing continues as it would have in the absence of the hook, unless the hook routine itself exits via goto, a loop exit, or a die.

    So, the die will still terminate your program. What are you trying to do with this? Quoth the Larry again:
    Do not attempt to build an exception-handling mechanism on this feature. Use eval {} to trap exceptions instead.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://585744]
Approved by ikegami
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2015-04-01 17:55 GMT
Find Nodes?
    Voting Booth?

    Who makes your decisions?

    Results (35 votes), past polls