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

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
[TCLion]: finaly finished the install wow that was over 10 min
[1nickt]: Corion using Moose will hardly reduce the number of dependencies or time to install DT !
[davido]: That's like wishing that your motorcycle came with a sherman tank as a trailer.
[Corion]: davido: No, more like my one sherman tank had a second sherman tank tied to its back ;)

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (8)
As of 2017-03-23 15:29 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (289 votes). Check out past polls.