projects
/
vrDialog
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
373992b
)
added read timeout
master
author
Dobrica Pavlinusic
<dpavlin@rot13.org>
Sun, 18 Jan 2015 22:06:00 +0000
(23:06 +0100)
committer
Dobrica Pavlinusic
<dpavlin@rot13.org>
Sun, 18 Jan 2015 22:06:00 +0000
(23:06 +0100)
dialog.pl
patch
|
blob
|
history
diff --git
a/dialog.pl
b/dialog.pl
index
381d1e4
..
d868ed9
100755
(executable)
--- a/
dialog.pl
+++ b/
dialog.pl
@@
-47,8
+47,16
@@
die "can't connect" unless $sock;
sub read_serial {
my $len = shift;
my $buffer;
- $sock->read( $buffer, $len );
- warn "## read $len ",as_hex($buffer) if $debug;
+ eval {
+ local $SIG{ALRM} = sub { die "read timeout" };
+ alarm 3;
+
+ warn "## read_serial $len" if $debug;
+ $sock->read( $buffer, $len );
+ warn "## read $len ",as_hex($buffer) if $debug;
+ };
+ alarm 0;
+ warn "ERROR: $@" if $@;
return $buffer;
}