From b58e750daf58c8d3c33c9713643e192fb815ab6c Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Wed, 29 Jan 2014 05:00:31 -0500 Subject: [PATCH] scripts/mosh: Fix hang when remote closes the connection Signed-off-by: Anders Kaseorg --- scripts/mosh.pl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/mosh.pl b/scripts/mosh.pl index 41c31b0..7cf69e1 100755 --- a/scripts/mosh.pl +++ b/scripts/mosh.pl @@ -219,11 +219,14 @@ if ( defined $fake_proxy ) { defined( my $pid = fork ) or die "$0: fork: $!\n"; if ( $pid == 0 ) { + close STDIN; cat $sock, \*STDOUT; $sock->shutdown( 0 ); _exit 0; } $SIG{ 'HUP' } = 'IGNORE'; + close STDOUT; cat \*STDIN, $sock; $sock->shutdown( 1 ); + close STDIN; waitpid $pid, 0; exit; }