in reply to command timeout not working

If I replace
my $pid = open my $sys, "-|", $command or die $!;
with
my $pid = open my $sys, "-|", sleep, 1000 or die $!;
I get COMMAND FAILURE! after the allotted timeout.

Replies are listed 'Best First'.
Re: Re: command timeout not working
by Anonymous Monk on May 14, 2004 at 14:31 UTC
    but what about $command?
    how does that fit into the picture with this solution?
    the goal was that if $command does not complete with in a certain amount of time it times out.
      I wasn't presenting a solution; I was just demonstating that if the command happens to be a simple UNIX process that hangs, your code does in fact correctly timeout (for me at least). You could take this as a starting point; firstly, does your code timeout for you too if you replace the command with a simple sleep? And if so, what is the diffence in behaviour between your command and the UNIX 'sleep' command that causes one to fail and not the other? Investigating that difference may lead to further clues.