scripts/mosh: Use fork instead of threads
For better support of non-threaded Perl installations. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
committed by
Keith Winstein
parent
b59f0f1482
commit
28f9cf7e4a
+7
-4
@@ -74,7 +74,7 @@ delete $ENV{ 'MOSH_PREDICTION_DISPLAY' };
|
|||||||
if ( defined $fake_proxy ) {
|
if ( defined $fake_proxy ) {
|
||||||
use Errno qw(EINTR);
|
use Errno qw(EINTR);
|
||||||
use IO::Socket::INET;
|
use IO::Socket::INET;
|
||||||
use threads;
|
use POSIX qw(_exit);
|
||||||
|
|
||||||
my ( $host, $port ) = @ARGV;
|
my ( $host, $port ) = @ARGV;
|
||||||
|
|
||||||
@@ -102,10 +102,13 @@ if ( defined $fake_proxy ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
my $thr = threads->create(sub { cat $sock, \*STDOUT; $sock->shutdown( 0 ); })
|
defined( my $pid = fork ) or die "$0: fork: $!\n";
|
||||||
or die "$0: create thread: $!\n";
|
if ( $pid == 0 ) {
|
||||||
|
cat $sock, \*STDOUT; $sock->shutdown( 0 );
|
||||||
|
_exit 0;
|
||||||
|
}
|
||||||
cat \*STDIN, $sock; $sock->shutdown( 1 );
|
cat \*STDIN, $sock; $sock->shutdown( 1 );
|
||||||
$thr->join;
|
waitpid $pid, 0;
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user