Subject: | [Patch] signal handling vs. i18n |
I ran into a strange problem using (so far very successfully) Net::Telnet
on Linux and perl 5.8.1:
A caught signal during an active telnet-session let the program break
completely with "read error: Unterbrechung während des Betriebssystemaufrufs".
After some desperate debugging I found the reason was the *languange* of
the error message! Unsetting $LANG solved the problem.
To have a more portable and permanent solution I replaced all regex tests
for $! by numeric test. Patch included.
Regards,
Thomas.
--- Net-Telnet-3.03/lib/Net/Telnet.pm.orig 2002-07-17 02:30:42.000000000 +0200
+++ Net-Telnet-3.03/lib/Net/Telnet.pm 2004-10-22 08:47:07.000000000 +0200
@@ -29,6 +29,7 @@
## Module import.
use Exporter ();
+use Errno qw(EINTR);
use Socket qw(AF_INET SOCK_STREAM inet_aton sockaddr_in);
use Symbol qw(qualify);
@@ -2125,7 +2126,7 @@
return $self->error("read timed-out");
}
else { # error waiting for input ready
- next if $! =~ /^interrupted/i;
+ next if $! == EINTR;
$s->{opened} = '';
return $self->error("read error: $!");
@@ -2146,7 +2147,7 @@
## Handle any read errors.
if (!defined $nread) { # read failed
- next if $! =~ /^interrupted/i; # restart interrupted syscall
+ next if $! == EINTR;
$s->{opened} = '';
return $self->error("read error: $!");
@@ -2999,7 +3000,7 @@
return $self->error("$subname timed-out");
}
else { # error waiting for output ready
- next if $! =~ /^interrupted/i;
+ next if $! == EINTR;
$s->{opened} = '';
return $self->error("write error: $!");
@@ -3011,7 +3012,7 @@
## Handle any write errors.
if (!defined $nwrote) { # write failed
- next if $! =~ /^interrupted/i; # restart interrupted syscall
+ next if $! == EINTR;
$s->{opened} = '';
return $self->error("write error: $!");