sniperd has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks! I need to make a system call in Windows and sometimes it times out and I'm trying to use alarm, however it looks like that doesn't work in windows (Activestate). Here is my code:
use warnings; use strict; main (); sub main { eval { local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required alarm 2; my $data = `ping 127.0.0.1 -t`; alarm 0; }; if ($@) { die unless $@ eq "alarm\n"; # propagate unexpected errors } else { print "got here\n"; } }
To keep it simple I just chucked in there ping -t for testing. The real code is calling phantomjs to hit a website and the .exe just blows up sometimes, basically getting stuck and I the script will just sit there. Is there some simple command I can use to call command line on windows and have it just die (or continue) if a certain number of seconds have passed? Thank you in advance.

Replies are listed 'Best First'.
Re: alarm in windows, alternative?
by BrowserUk (Patriarch) on Mar 06, 2015 at 16:16 UTC

    See Re: Backticks and SIGALRM for a method that works with AS perl.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    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". I'm with torvalds on this
    In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked