Subject: | IPC::Run::run not timeout properly when run command via ssh |
If I run an external command on localhost using IPC::Run, I can timeout
it properly
my ($in, $out, $err, @cmd);
@cmd = ("/bin/true”);
run \@cmd, \$in, \$out, \$err, timeout(5), debug => 1;
The above script would finish in less than 0.1 seconds. However, if the
command contains ssh, i.e., I am running the command on another host via
ssh, timeout doesn’t work:
@cmd = ("ssh", "anotherhost", "/bin/true");
run \@cmd, \$in, \$out, \$err, timeout(5);
This code would take 6.534 seconds to finish. Note that I am using a
dummy hostname above. For the actual host, ssh works fine. Running the
entire command including ssh in a shell finishes in less than one
second. If I increase the timeout, the time it took to finish would
increase accordingly. For example, if the timeout is set to 10 seconds,
the actual time it took the script to finish would be 11.529 seconds.
I'd appreciate if anybody has any input on this, or maybe I am missing
something in the doc completely?
Thanks
J Bao