pubscout has asked for the wisdom of the Perl Monks concerning the following question:
I'm using an alarm for the global timeout control, which by itself works as expected, but as soon as I add a few Net::Telnet object calls the alarm exception does not seem to propagate.
My next intention is to handle dropped connections by receiving Net::Telnet specific exceptions and returning to the telnet_connect label to reconnect and retry, all within the same timeout eval scope.eval { local $SIG{ALRM} = sub (die "timeout\n"); alarm 5; telnet_connect: #label for later handling of dropped sessions my $t = new Net::Telnet(); # Even with the new() line above the alarm fires # Adding the lines below stop the alarm from working $t->open($host) $t->login($user, $pass); while (1) { # Interact w/telnet session until we're happy # This loop is always reached in testing } $t->close() alarm 0; }; if ($@) { if ($@ =~ /timeout/) { print "Timed out!"; } else { print "Received exception: $@\n"; alarm 0; die; } }
The first question is why does the alarm fail to trigger with the addition of the Net::Telnet object, even when setting PERL_SIGNALS=unsafe ?
Secondly, is this the best way to handle reconnecting to dropped telnet sessions while being governed by a global timeout?
Thanks in advance for any glimpse of enlightenment!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Alarm and Telnet issues
by themage (Friar) on Dec 27, 2006 at 16:59 UTC | |
by pubscout (Initiate) on Dec 27, 2006 at 20:04 UTC | |
by Anonymous Monk on Dec 28, 2006 at 01:31 UTC | |
|
Re: Alarm and Telnet issues
by EvanK (Chaplain) on Dec 27, 2006 at 16:48 UTC |