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

Re: Setting signal handlers

by Hue-Bond (Priest)
on May 09, 2006 at 20:55 UTC ( #548326=note: print w/replies, xml ) Need Help??


in reply to Setting signal handlers

That's the POSIX way to do things. It's as ugly in Perl as it's in C, since in C it's also done a la POSIX. Fortunately in Perl we have Another Way To Do It:

sub interrupt { print "quitting!\n"; } $SIG{'INT'} = 'interrupt'; sleep 20; __END__ ^C quitting!

--
David Serrano

Replies are listed 'Best First'.
Re^2: Setting signal handlers
by andyford (Curate) on May 09, 2006 at 21:17 UTC
    Thanks David but

    I tried that first and it didn't work. Supposedly it's because "POSIX unmasks the sigprocmask properly".

    Not sure what that means, but the POSIX way works and the Perl way doesn't.

      What did you try exactly? Without some code it's difficult to guess why it's not working for you. You should post a small complete program that shows the problem and tell us what do you expect and what is happening instead.

      --
      David Serrano

      Well, back in 2000, I gave up on a module (Server::FastPL, now on backpan) because of lost signals and unix sockets constant lock up... My experience told me to not trust signals for anything really important... I did use the $SIG way... maybe the problem is related...

      daniel
        In perl 5.8.0, released in 2002, we introduced the concept of 'safe signals'. This makes the perl interpreter interruptable onbly on opcode boundaries. This removed a lot of the reentrancy and race problems that perl used to have handling signals, at the risk of sometimes delaying the handling of the signal.

        You may want to see if your old signal code workes better now.

        Dave.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2021-03-07 03:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favorite kind of desktop background is:











    Results (119 votes). Check out past polls.

    Notices?