From 9b51ae6f7cd5c6e3f480d446a186a46a5bab8bfa Mon Sep 17 00:00:00 2001 From: root Date: Fri, 28 May 2021 19:47:21 +0100 Subject: fish --- heating-cgi/boiler_rx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'heating-cgi/boiler_rx') diff --git a/heating-cgi/boiler_rx b/heating-cgi/boiler_rx index 777b3ee..f794e1b 100755 --- a/heating-cgi/boiler_rx +++ b/heating-cgi/boiler_rx @@ -35,10 +35,19 @@ while (1) { my $nodata = 0; while ( ( not $telnet->eof ) and ( $nodata < $timeout ) ) { - my $line = $telnet->getline( Timeout => 1, Errmode => 'return' ); + my $line = undef; + eval { + local $SIG{ALRM} = sub { die 'Timed Out'; }; + alarm 2; + + $line = $telnet->getline( Timeout => 1, Errmode => 'return' ); + alarm 0; + }; + alarm 0; if ( not defined $line or ( length($line) == 0 ) ) { $nodata++; + next; } else { $nodata = 0; -- cgit v1.2.3