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 @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";
|
||||
|
||||
Reference in New Issue
Block a user