in reply to Re: get() from website hangs
in thread get() from website hangs
#!/usr/bin/perl use strict; use warnings; my $delay = shift @ARGV || 1; # parameter my $timeout = 3; # seconds eval { ## Turn on timer. local $SIG{"__DIE__"}; local $SIG{CHLD}; local $SIG{ALRM} = sub { die "timed-out\n" }; alarm $timeout; my $verylongprocess = `sleep $delay`; alarm 0; # disable alarm }; die $@ if $@ eq "timed-out\n"; print "No timeout\n";
it should cover external processes (hence, the 3 local SIG's). Not sure it works on Windows. But give it a try.
edit 2: Yes, it works, but instead of the unix "sleep" use the Windows "timeout" command (available in W7 and W10), like so:
my $verylongprocess = `timeout $delay`;
|
---|