Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: Signals in Strawberry Perl: Name or number?

by cdarke (Prior)
on Sep 13, 2009 at 11:09 UTC ( #794983=note: print w/replies, xml ) Need Help??

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

This was my test code:
#!/usr/bin/perl use strict; use warnings; $SIG{ALRM} = sub { print "Alarming!\n"; }; kill 'ALRM', $$; print "Not alarming\n";
(The quotes around 'ALRM' required for strict).
I don't have Strawberry Perl, but I tried it on ActiveState Perl 5.10.1 and got the same result, i.e. no output. I tried it on 5.10.0 on Cygwin and 5.8.8 on CentOS(Linux) and it worked correctly, i.e.
Alarming! Not alarming
On Windows and ActiveState perl, tracing shows that it does exit on the kill. I tried the same with an INT signal and that did not work either, however the symptoms were different. It did not execute the signal handler but it did not crash either.

The ActiveState documentation says that alarm is not supported and signals are not properly supported anyhow. It's a Windows thing, but neither implementation should just drop-out without so much as a 'sorry'. The code is perfectly legal, if a bit of an edge case.

Replies are listed 'Best First'.
Re^2: Signals in Strawberry Perl: Name or number?
by Marshall (Abbot) on Sep 13, 2009 at 18:07 UTC
    On Windows XP, ActiveState 5.10 you will get:
    Process completed with exit code 14

    There is a problem with "kill", not with ALRM signal.

    And SIG INT works also!

    #!/usr/bin/perl use strict; use warnings; while (1) { sleep(1); } __END__ Terminating on signal SIGINT(2) Process completed with exit code 2
    ....This was CTRL-Break....

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://794983]
[talexb]: Good morning. Or, good localtime.

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (10)
As of 2017-06-26 15:08 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (583 votes). Check out past polls.