http://www.perlmonks.org?node_id=815527


in reply to Re^2: $SIG{ALRM} and windows vista?
in thread $SIG{ALRM} and windows vista?

Not on my Vista system.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"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^4: $SIG{ALRM} and windows vista?
by ikegami (Patriarch) on Jan 04, 2010 at 06:58 UTC

    It sounds like you're saying that signals don't interrupt I/O on Windows, but you know that only thing that Windows has that is similar to signals are Ctrl-C and Ctrl-Break. Are you saying they don't interrupt I/O? I haven't tested how they work.

    Update: Clarified.

      Windows doesn't have signals

      No, but it simulates some of them:

      use strict; use warnings; use 5.010; print 'Enter your password: '; my $password = eval { local $SIG{ALRM} = sub {die "timeout\n"}; alarm 5; # return <STDIN>; sleep 10; }; alarm 0; if ($@ =~ /timeout/) { print "You timed out.\n"; } __END__ [ 7:18:01.22] C:\test>alarmit.pl Enter your password: You timed out.

      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

        A little bit of bean counting:

        Windows has no signals, and it does not emulate them. It's perl that implements an incomplete emulation of Unix signals, without support from Windows.

        From perlport:

        Don't count on signals or %SIG for anything.

        Alexander

        --
        Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

        On Windows Vista, your code doesn't do anything useful. Specifically, your code fails to display the message "Enter your password:" and then wait for the user to enter their password. Instead, your code does nothing, then prints out "Enter your password: you timed out."

        In an effort to get "Enter your password: " to display immediately, I tried setting the output buffer to flush output immediately by setting $| = 1, but that didn't change the result.