Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: win32, ctrl-c, sleep, and signals

by BrowserUk (Patriarch)
on May 30, 2006 at 15:41 UTC ( [id://552527]=note: print w/replies, xml ) Need Help??


in reply to win32, ctrl-c, sleep, and signals

This is caused by the 'safe signals' that were introduced by 5.8.0. The sleep is treated a single opcode and so the signal is not seen until after the opcode completes. See the 'safe signals' section of perl58delta. Also see perl581delta for how to bypass this and get the old unsafe behaviour back.

c:\test>set PERL_SIGNALS=unsafe c:\test>p1 [0] Perl> $SIG{ INT } = sub{ print 'Caught signal INT'; };; [0] Perl> print 'still here' while sleep 10;; still here Caught signal INT still here Terminating on signal SIGBREAK(21)

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: win32, ctrl-c, sleep, and signals
by SirBones (Friar) on May 30, 2006 at 16:38 UTC
    This is caused by the 'safe signals' that were introduced by 5.8.0.

    Fair enough, but that doesn't seem to explain why I get different behavior on Linux (immediate exit), where I'm running Perl 5.8.0.

    Thanks,
    Ken

    "This bounty hunter is my kind of scum: Fearless and inventive." --J.T. Hutt

      You have to remember that Win32 does not have signals as a native concept. Perl's support for them is simulated and limited, and is actually implemented via the process message queue. This is the code that implements the signal emulations from win32.c:

      Setting the environment variable PERL_SIGNALS=unsafe allows ^C to interupt sleep. Without it, the signal handler doesn't get invoked until the sleep is over.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
Re^2: win32, ctrl-c, sleep, and signals
by sgifford (Prior) on May 30, 2006 at 16:40 UTC
    Are you sure? It works fine for me on Unix with perl 5.8.3. It seems to me that sleep would qualify as a "potentially blocking operation" mentioned in perl58delta...
      Are you sure?

      Yes. See Re^3: win32, ctrl-c, sleep, and signals.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (5)
As of 2024-04-16 06:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found