From 1f05ffce2ad265c686a7cb113e2b2f5e2fbc3046 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 3 Jul 2009 23:27:30 -0500 Subject: check for eof/error properly --- lib/App/Termcast.pm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/App/Termcast.pm b/lib/App/Termcast.pm index 9f7adca..a189060 100644 --- a/lib/App/Termcast.pm +++ b/lib/App/Termcast.pm @@ -63,17 +63,22 @@ sub run { if (vec($rout, fileno(STDIN), 1)) { my $buf; sysread STDIN, $buf, 4096; + if (!$buf) { + warn "Error reading from stdin: $!" unless defined $buf; + last; + } $pty->write($buf); } if (vec($rout, fileno($pty->{pty}), 1)) { my $buf = $pty->read(0); + if (!$buf) { + warn "Error reading from pty: $!" unless defined $buf; + last; + } syswrite STDOUT, $buf; $socket->write($buf); } } - if ($!) { - warn "Error reading: $!\n"; - } } __PACKAGE__->meta->make_immutable; -- cgit v1.2.3-54-g00ecf