Not getting the desired behavior from the alarm function on WinXP Activestate Perl 5.8.6. It alarms at 1 sec, nothing greater.
Reading the release notes I see where signals are handled after a operation is complete. So I guess this is expected behaviour or is something else going on here?
Any sugestions on how to make a timer on my ssh session without using alarm()?
use strict;
use Net::SSH::Perl; #Use this perl mod to create the SSH session.
use Net::SSH::W32Perl;
my $host = "";
my $user = "";
my $pw = "";
sub error {
die "ERROR! ERROR! ERROR! @_";
}
sub ssh_cmd{
my $ssh = new Net::SSH::W32Perl($host);
$ssh->login($user, $pw);
my $cmd = "./test_alarm.pl > test_alarm.out 2>&1";
my ($out, $err, $exit) = $ssh->cmd($cmd,"\n");
}
my $TIMEOUT = 2; # seconds
eval {
local $SIG{ALRM} = sub { die "alarm\n" };
alarm $TIMEOUT;
ssh_cmd();
alarm 0;
};
if ($@) {
if($@ eq "alarm\n") {
error("OPERATION TIMED OUT!");
} else {
error("your_code() generated errors: $@");
}
}