Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: Signals in Strawberry Perl: Name or number?

by Crackers2 (Vicar)
on Sep 13, 2009 at 02:06 UTC ( #794960=note: print w/ replies, xml ) Need Help??


in reply to Re: Signals in Strawberry Perl: Name or number?
in thread Signals in Strawberry Perl: Name or number?

kill ALRM, $$ doesn't make sense to me!

It means "send an ALRM signal to the process with PID $$ (which mean the current process). While it may not make much sense in production code, it's certainly useful for testing.

You may want to reread the docs for kill; unlike the shell version, the perl version requires you to have the signal as first parameter, followed by the PIDs you want to send the signal to.


Comment on Re^2: Signals in Strawberry Perl: Name or number?
Re^3: Signals in Strawberry Perl: Name or number?
by Marshall (Prior) on Sep 13, 2009 at 04:33 UTC
    When I test code with ALRM signal, I fiddle with the alarm($num) parameter and often use sleep() to cause the alarm to "trigger" during testing. There are problems with signal handling...in general, there is no way to "safely" continue executing a process after an ALRM signal because many OS functions are not re-entrant or even re-startable by any means.

    Update: I strike this last sentence because it upset some folks. No offense was intended. I have no interest in obfuscated, obscure code although I do see that some folks have fun with this as an "art form".

    The original question was, why doesn't this code work?

    sub verse4 { my $boy; $SIG{ALRM} = sub { say "slip n slide" }; ride( $boy ), kill (ALRM, $$) for (1 .. 3); sleep 1; map { $_++ } ($ice_cream, $cake); } sub ride { say "Whee!" };

      There's no difference between receiving an alarm that was sent via alarm or via kill. What makes you think that the latter can trigger signals when the former can't?

      What's obfuscated about sending a signal with kill, whose very purpose is to send signals?

        There's no difference between receiving an alarm that was sent via alarm or via kill. What makes you think that the latter can trigger signals when the former can't?

        I didn't say that there was a difference. I explained very clearly how to use the alarm signal in a normal application. A signal is a "message" from the OS.

        What's obfuscated about sending a signal with kill, whose very purpose is to send signals?

        What is obfuscated is this "poetry" idea and using language constructs in "unnatural ways". I have no problem with strange code as an art form.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (9)
As of 2014-08-21 12:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (135 votes), past polls