Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

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.

Replies are listed 'Best First'.
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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2018-06-20 19:03 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (117 votes). Check out past polls.