in reply to Re: get() from website hangs
in thread get() from website hangs

I offer you this bit of code you can play with (try it with parameter 2 and then with parameter 4):

#!/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`;