Permalink
Browse files

Replace IO::Pty with pipe

Now when we don't need some fancy pty for sending on window-size and
reading proxy-output from, just use a regular pipe to drop dependency on
IO::Pty
  • Loading branch information...
1 parent 4976eff commit 3fa71d7998643b8bcc214984354593480b7c3dd0 @glance- committed Jan 17, 2013
Showing with 9 additions and 14 deletions.
  1. +9 −14 scripts/mosh
View
23 scripts/mosh
@@ -195,12 +195,6 @@ if ( scalar @ARGV < 1 ) {
my $userhost = shift;
my @command = @ARGV;
-# Run SSH and read password
-my $pty = new IO::Pty;
-my $pty_slave = $pty->slave;
-
-$pty_slave->clone_winsize_from( \*STDIN );
-
# Count colors
open COLORCOUNT, '-|', $client, ('-c') or die "Can't count colors: $!\n";
my $colors = "";
@@ -218,14 +212,15 @@ if ( (not defined $colors)
$colors = 0;
}
+my ($p_read, $p_write);
+pipe($p_read, $p_write);
my $pid = fork;
die "$0: fork: $!\n" unless ( defined $pid );
if ( $pid == 0 ) { # child
- $pty->close_slave();
- open STDOUT, ">&", $pty or die;
- open STDERR, ">&", $pty or die;
- open STDIN, "<&", $pty or die;
- close $pty;
+ open STDOUT, ">&", $p_write or die;
+ open STDERR, ">&", $p_write or die;
+ close $p_write;
+ close $p_read;
my @server = ( 'new', '-s' );
@@ -249,8 +244,8 @@ if ( $pid == 0 ) { # child
} else { # parent
my ( $ip, $port, $key );
my $bad_udp_port_warning = 0;
- close $pty;
- LINE: while ( <$pty_slave> ) {
+ close $p_write;
+ LINE: while ( <$p_read> ) {
chomp;
if ( m{^MOSH IP } ) {
if ( defined $ip ) {
@@ -271,7 +266,7 @@ if ( $pid == 0 ) { # child
}
}
waitpid $pid, 0;
- close $pty_slave;
+ close $p_read;
if ( not defined $ip ) {
die "$0: Did not find remote IP address (is SSH ProxyCommand disabled?).\n";

0 comments on commit 3fa71d7

Please sign in to comment.