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 [closes #378]
This commit is contained in:
committed by
Keith Winstein
parent
e0dfe363a0
commit
74e1a30944
+9
-14
@@ -195,12 +195,6 @@ if ( scalar @ARGV < 1 ) {
|
|||||||
my $userhost = shift;
|
my $userhost = shift;
|
||||||
my @command = @ARGV;
|
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
|
# Count colors
|
||||||
open COLORCOUNT, '-|', $client, ('-c') or die "Can't count colors: $!\n";
|
open COLORCOUNT, '-|', $client, ('-c') or die "Can't count colors: $!\n";
|
||||||
my $colors = "";
|
my $colors = "";
|
||||||
@@ -218,14 +212,15 @@ if ( (not defined $colors)
|
|||||||
$colors = 0;
|
$colors = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my ($p_read, $p_write);
|
||||||
|
pipe($p_read, $p_write);
|
||||||
my $pid = fork;
|
my $pid = fork;
|
||||||
die "$0: fork: $!\n" unless ( defined $pid );
|
die "$0: fork: $!\n" unless ( defined $pid );
|
||||||
if ( $pid == 0 ) { # child
|
if ( $pid == 0 ) { # child
|
||||||
$pty->close_slave();
|
open STDOUT, ">&", $p_write or die;
|
||||||
open STDOUT, ">&", $pty or die;
|
open STDERR, ">&", $p_write or die;
|
||||||
open STDERR, ">&", $pty or die;
|
close $p_write;
|
||||||
open STDIN, "<&", $pty or die;
|
close $p_read;
|
||||||
close $pty;
|
|
||||||
|
|
||||||
my @server = ( 'new', '-s' );
|
my @server = ( 'new', '-s' );
|
||||||
|
|
||||||
@@ -249,8 +244,8 @@ if ( $pid == 0 ) { # child
|
|||||||
} else { # parent
|
} else { # parent
|
||||||
my ( $ip, $port, $key );
|
my ( $ip, $port, $key );
|
||||||
my $bad_udp_port_warning = 0;
|
my $bad_udp_port_warning = 0;
|
||||||
close $pty;
|
close $p_write;
|
||||||
LINE: while ( <$pty_slave> ) {
|
LINE: while ( <$p_read> ) {
|
||||||
chomp;
|
chomp;
|
||||||
if ( m{^MOSH IP } ) {
|
if ( m{^MOSH IP } ) {
|
||||||
if ( defined $ip ) {
|
if ( defined $ip ) {
|
||||||
@@ -271,7 +266,7 @@ if ( $pid == 0 ) { # child
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
waitpid $pid, 0;
|
waitpid $pid, 0;
|
||||||
close $pty_slave;
|
close $p_read;
|
||||||
|
|
||||||
if ( not defined $ip ) {
|
if ( not defined $ip ) {
|
||||||
die "$0: Did not find remote IP address (is SSH ProxyCommand disabled?).\n";
|
die "$0: Did not find remote IP address (is SSH ProxyCommand disabled?).\n";
|
||||||
|
|||||||
Reference in New Issue
Block a user