Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2014-12-25 17:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (161 votes), past polls