Fix lost MOSH CONNECT on FreeBSD 11
This moves all routine stdout/stderr output into the parent server, and adds tcdrain(), even though this may be a FreeBSD pty bug.
This commit is contained in:
+19
-11
@@ -409,7 +409,6 @@ static int run_server( const char *desired_ip, const char *desired_port,
|
|||||||
}
|
}
|
||||||
|
|
||||||
printf( "\nMOSH CONNECT %s %s\n", network->port().c_str(), network->get_key().c_str() );
|
printf( "\nMOSH CONNECT %s %s\n", network->port().c_str(), network->get_key().c_str() );
|
||||||
fflush( stdout );
|
|
||||||
|
|
||||||
/* don't let signals kill us */
|
/* don't let signals kill us */
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
@@ -421,25 +420,34 @@ static int run_server( const char *desired_ip, const char *desired_port,
|
|||||||
|
|
||||||
|
|
||||||
/* detach from terminal */
|
/* detach from terminal */
|
||||||
|
fflush( stdout );
|
||||||
|
fflush( stderr );
|
||||||
pid_t the_pid = fork();
|
pid_t the_pid = fork();
|
||||||
if ( the_pid < 0 ) {
|
if ( the_pid < 0 ) {
|
||||||
perror( "fork" );
|
perror( "fork" );
|
||||||
} else if ( the_pid > 0 ) {
|
} else if ( the_pid > 0 ) {
|
||||||
|
fprintf( stderr, "\nmosh-server (%s) [build %s]\n", PACKAGE_STRING, BUILD_VERSION );
|
||||||
|
fprintf( stderr, "Copyright 2012 Keith Winstein <mosh-devel@mit.edu>\n" );
|
||||||
|
fprintf( stderr, "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.\n\n" );
|
||||||
|
|
||||||
|
fprintf( stderr, "[mosh-server detached, pid = %d]\n", static_cast<int>(the_pid) );
|
||||||
|
#ifndef HAVE_IUTF8
|
||||||
|
fprintf( stderr, "\nWarning: termios IUTF8 flag not defined.\nCharacter-erase of multibyte character sequence\nprobably does not work properly on this platform.\n" );
|
||||||
|
#endif /* HAVE_IUTF8 */
|
||||||
|
|
||||||
|
fflush( stdout );
|
||||||
|
fflush( stderr );
|
||||||
|
if ( isatty( STDOUT_FILENO ) ) {
|
||||||
|
tcdrain( STDOUT_FILENO );
|
||||||
|
}
|
||||||
|
if ( isatty( STDERR_FILENO ) ) {
|
||||||
|
tcdrain( STDERR_FILENO );
|
||||||
|
}
|
||||||
_exit( 0 );
|
_exit( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf( stderr, "\nmosh-server (%s) [build %s]\n", PACKAGE_STRING, BUILD_VERSION );
|
|
||||||
fprintf( stderr, "Copyright 2012 Keith Winstein <mosh-devel@mit.edu>\n" );
|
|
||||||
fprintf( stderr, "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.\n\n" );
|
|
||||||
|
|
||||||
fprintf( stderr, "[mosh-server detached, pid = %d]\n", (int)getpid() );
|
|
||||||
|
|
||||||
int master;
|
int master;
|
||||||
|
|
||||||
#ifndef HAVE_IUTF8
|
|
||||||
fprintf( stderr, "\nWarning: termios IUTF8 flag not defined.\nCharacter-erase of multibyte character sequence\nprobably does not work properly on this platform.\n" );
|
|
||||||
#endif /* HAVE_IUTF8 */
|
|
||||||
|
|
||||||
/* close file descriptors */
|
/* close file descriptors */
|
||||||
if ( !verbose ) {
|
if ( !verbose ) {
|
||||||
/* Necessary to properly detach on old versions of sshd (e.g. RHEL/CentOS 5.0). */
|
/* Necessary to properly detach on old versions of sshd (e.g. RHEL/CentOS 5.0). */
|
||||||
|
|||||||
Reference in New Issue
Block a user