mosh: "Fix hang when remote closes the connection"

Merge
  b58e750daf
into the C++ wrapper script.
This commit is contained in:
Fredrik Fornwall 2016-05-27 09:07:05 +02:00
parent 1f87518b8c
commit 3afa4f345a
1 changed files with 7 additions and 6 deletions

View File

@ -317,13 +317,16 @@ int main( int argc, char *argv[] )
int pid = fork();
if ( pid == -1 ) die( "%s: fork: %d", argv[0], errno );
if ( pid == 0 ) {
cat( sockfd, 1 );
close( STDIN_FILENO );
cat( sockfd, STDOUT_FILENO );
shutdown( sockfd, 0 );
exit( 0 );
}
signal( SIGHUP, SIG_IGN );
cat( 0, sockfd );
shutdown( sockfd, 1 );
close( STDOUT_FILENO );
cat( STDIN_FILENO, sockfd );
shutdown( sockfd, SHUT_WR /* = 1 */ );
close( STDIN_FILENO );
waitpid( pid, NULL, 0 );
exit( 0 );
}
@ -367,9 +370,7 @@ int main( int argc, char *argv[] )
}
int pid = fork();
if ( pid == -1 ) {
die( "%s: fork: %d", argv[0], errno );
}
if ( pid == -1 ) die( "%s: fork: %d", argv[0], errno );
if ( pid == 0 ) {
close( pty );
if ( -1 == dup2( pty_slave, 1 ) ||