diff options
-rwxr-xr-x | emergencyc.pl | 7 | ||||
-rwxr-xr-x | emergencyd.pl | 1 |
2 files changed, 6 insertions, 2 deletions
diff --git a/emergencyc.pl b/emergencyc.pl index 86c9da7..5d59be1 100755 --- a/emergencyc.pl +++ b/emergencyc.pl @@ -77,10 +77,13 @@ eval { alarm 5; do { $sender = recv($socket, $buf, 16384, 0); - } while ( $sender ne $haddr ); + } while ( defined($sender) && $sender ne $haddr ); }; if ( $@ ) { - printf "timeout\n"; + print "timeout\n"; + exit 1; +} elsif ( !defined($sender) ) { + die "Failed to receive packet: $!"; } else { printf "%s", $buf; } diff --git a/emergencyd.pl b/emergencyd.pl index f2fed7a..47c39e4 100755 --- a/emergencyd.pl +++ b/emergencyd.pl @@ -131,6 +131,7 @@ PACKET: while (1) { my $buf; my $sender = recv($socket, $buf, 16384, 0); + die "Failed to receive packet: $!" unless defined($sender); my @lines = split /\015*\012|\|/s, $buf; my $command = $lines[0] // ""; my $timestamp = $lines[1] // ""; |