On May 11, 9:29 pm, dery...@gmail.com ("C.DeRykus") wrote:
> On May 11, 12:56 am, weizhong....@gmail.com (Weizhong Dai) wrote:
>
>> ...
>
> $pid = open(my $readme, "program arguments |")
>                   or die "Couldn't fork: $!\n";
> my $timeout = 5;
> eval {
>     local $SIG{ALRM} = sub { die "timeout"; };
>     alarm( $timeout );
>     print while <$readme>;
>     alarm(0);
>     1;}  or die "eval error: $@ ";

Warning: This works on Unix but  alarm() won't interrupt
a blocking system call on Win32. The Win32::Job module
is recommended in that case.

--
Charles DeRykus


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to