summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2009-07-06 22:48:06 -0500
committerJesse Luehrs <doy@tozt.net>2009-07-06 22:48:06 -0500
commit35d4d083d63a4f2590978cf5dc60a0f47043fda7 (patch)
treef2fa0f7c274adb0f6be172a7dc08db112b85ea03
parentd4247cdd28a32f5c9eca291239df5ddb93cd9e1d (diff)
downloadapp-termcast-35d4d083d63a4f2590978cf5dc60a0f47043fda7.tar.gz
app-termcast-35d4d083d63a4f2590978cf5dc60a0f47043fda7.zip
don't need to keep calling fileno on the pty
-rw-r--r--lib/App/Termcast.pm9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/App/Termcast.pm b/lib/App/Termcast.pm
index 11ea3e2..62e5bc3 100644
--- a/lib/App/Termcast.pm
+++ b/lib/App/Termcast.pm
@@ -52,15 +52,16 @@ sub run {
my $pty = IO::Pty::Easy->new;
$pty->spawn(@argv);
+ my $ptyfd = fileno($pty);
my $termios = POSIX::Termios->new;
- $termios->getattr(fileno($pty));
+ $termios->getattr($ptyfd);
my $lflag = $termios->getlflag;
$termios->setlflag($lflag | POSIX::ECHO);
- $termios->setattr(fileno($pty), POSIX::TCSANOW);
+ $termios->setattr($ptyfd, POSIX::TCSANOW);
my ($rin, $rout) = '';
vec($rin, fileno(STDIN) ,1) = 1;
- vec($rin, fileno($pty), 1) = 1;
+ vec($rin, $ptyfd, 1) = 1;
ReadMode 4;
while (1) {
my $ready = select($rout = $rin, undef, undef, undef);
@@ -73,7 +74,7 @@ sub run {
}
$pty->write($buf);
}
- if (vec($rout, fileno($pty), 1)) {
+ if (vec($rout, $ptyfd, 1)) {
my $buf = $pty->read(0);
if (!$buf) {
warn "Error reading from pty: $!" unless defined $buf;