Skip to content

Commit

Permalink
Replace IO::Pty with pipe
Browse files Browse the repository at this point in the history
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

[closes #378]
  • Loading branch information
glance- authored and keithw committed Jan 18, 2013
1 parent e0dfe36 commit 74e1a30
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions scripts/mosh
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Expand All @@ -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' );

Expand All @@ -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 ) {
Expand All @@ -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";
Expand Down

0 comments on commit 74e1a30

Please sign in to comment.