From 35d4d083d63a4f2590978cf5dc60a0f47043fda7 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Mon, 6 Jul 2009 22:48:06 -0500 Subject: don't need to keep calling fileno on the pty --- lib/App/Termcast.pm | 9 +++++---- 1 file 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; -- cgit v1.2.3-54-g00ecf