diff options
author | Jesse Luehrs <doy@tozt.net> | 2009-07-03 23:27:30 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2009-07-03 23:27:30 -0500 |
commit | 1f05ffce2ad265c686a7cb113e2b2f5e2fbc3046 (patch) | |
tree | c16c21e4e2240b1e7c48f2105d65b0e98ad8c5a4 | |
parent | 86aa2b015c556a292fbc63111d0fae4315431608 (diff) | |
download | app-termcast-1f05ffce2ad265c686a7cb113e2b2f5e2fbc3046.tar.gz app-termcast-1f05ffce2ad265c686a7cb113e2b2f5e2fbc3046.zip |
check for eof/error properly
-rw-r--r-- | lib/App/Termcast.pm | 11 |
1 files 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; |