Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit 3fa71d7998643b8bcc214984354593480b7c3dd0 1 parent 4976eff
Anton Lundin authored January 18, 2013

Showing 1 changed file with 9 additions and 14 deletions. Show diff stats Hide diff stats

  1. 23  scripts/mosh
23  scripts/mosh
@@ -195,12 +195,6 @@ if ( scalar @ARGV < 1 ) {
195 195
 my $userhost = shift;
196 196
 my @command = @ARGV;
197 197
 
198  
-# Run SSH and read password
199  
-my $pty = new IO::Pty;
200  
-my $pty_slave = $pty->slave;
201  
-
202  
-$pty_slave->clone_winsize_from( \*STDIN );
203  
-
204 198
 # Count colors
205 199
 open COLORCOUNT, '-|', $client, ('-c') or die "Can't count colors: $!\n";
206 200
 my $colors = "";
@@ -218,14 +212,15 @@ if ( (not defined $colors)
218 212
   $colors = 0;
219 213
 }
220 214
 
  215
+my ($p_read, $p_write);
  216
+pipe($p_read, $p_write);
221 217
 my $pid = fork;
222 218
 die "$0: fork: $!\n" unless ( defined $pid );
223 219
 if ( $pid == 0 ) { # child
224  
-  $pty->close_slave();
225  
-  open STDOUT, ">&", $pty or die;
226  
-  open STDERR, ">&", $pty or die;
227  
-  open STDIN, "<&", $pty or die;
228  
-  close $pty;
  220
+  open STDOUT, ">&", $p_write or die;
  221
+  open STDERR, ">&", $p_write or die;
  222
+  close $p_write;
  223
+  close $p_read;
229 224
 
230 225
   my @server = ( 'new', '-s' );
231 226
 
@@ -249,8 +244,8 @@ if ( $pid == 0 ) { # child
249 244
 } else { # parent
250 245
   my ( $ip, $port, $key );
251 246
   my $bad_udp_port_warning = 0;
252  
-  close $pty;
253  
-  LINE: while ( <$pty_slave> ) {
  247
+  close $p_write;
  248
+  LINE: while ( <$p_read> ) {
254 249
     chomp;
255 250
     if ( m{^MOSH IP } ) {
256 251
       if ( defined $ip ) {
@@ -271,7 +266,7 @@ if ( $pid == 0 ) { # child
271 266
     }
272 267
   }
273 268
   waitpid $pid, 0;
274  
-  close $pty_slave;
  269
+  close $p_read;
275 270
 
276 271
   if ( not defined $ip ) {
277 272
       die "$0: Did not find remote IP address (is SSH ProxyCommand disabled?).\n";

0 notes on commit 3fa71d7

Please sign in to comment.
Something went wrong with that request. Please try again.