mosh-server: improve error logging
Also stop using _exit(), believed unnecessary now with proper stdio flushing.
This commit is contained in:
@@ -451,8 +451,7 @@ static int run_server( const char *desired_ip, const char *desired_port,
|
|||||||
|
|
||||||
|
|
||||||
/* detach from terminal */
|
/* detach from terminal */
|
||||||
fflush( stdout );
|
fflush( NULL );
|
||||||
fflush( stderr );
|
|
||||||
pid_t the_pid = fork();
|
pid_t the_pid = fork();
|
||||||
if ( the_pid < 0 ) {
|
if ( the_pid < 0 ) {
|
||||||
perror( "fork" );
|
perror( "fork" );
|
||||||
@@ -470,15 +469,14 @@ static int run_server( const char *desired_ip, const char *desired_port,
|
|||||||
"probably does not work properly on this platform.\n", stderr );
|
"probably does not work properly on this platform.\n", stderr );
|
||||||
#endif /* HAVE_IUTF8 */
|
#endif /* HAVE_IUTF8 */
|
||||||
|
|
||||||
fflush( stdout );
|
fflush( NULL );
|
||||||
fflush( stderr );
|
|
||||||
if ( isatty( STDOUT_FILENO ) ) {
|
if ( isatty( STDOUT_FILENO ) ) {
|
||||||
tcdrain( STDOUT_FILENO );
|
tcdrain( STDOUT_FILENO );
|
||||||
}
|
}
|
||||||
if ( isatty( STDERR_FILENO ) ) {
|
if ( isatty( STDERR_FILENO ) ) {
|
||||||
tcdrain( STDERR_FILENO );
|
tcdrain( STDERR_FILENO );
|
||||||
}
|
}
|
||||||
_exit( 0 );
|
exit( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
int master;
|
int master;
|
||||||
@@ -596,15 +594,13 @@ static int run_server( const char *desired_ip, const char *desired_port,
|
|||||||
/* Wait for parent to release us. */
|
/* Wait for parent to release us. */
|
||||||
char linebuf[81];
|
char linebuf[81];
|
||||||
if (fgets(linebuf, sizeof linebuf, stdin) == NULL) {
|
if (fgets(linebuf, sizeof linebuf, stdin) == NULL) {
|
||||||
perror( "parent signal" );
|
err( 1, "parent signal" );
|
||||||
_exit( 1 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Crypto::reenable_dumping_core();
|
Crypto::reenable_dumping_core();
|
||||||
|
|
||||||
if ( execvp( command_path.c_str(), command_argv ) < 0 ) {
|
if ( execvp( command_path.c_str(), command_argv ) < 0 ) {
|
||||||
perror( "execvp" );
|
err( 1, "execvp: %s", command_path.c_str() );
|
||||||
_exit( 1 );
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* parent */
|
/* parent */
|
||||||
@@ -826,8 +822,7 @@ static void serve( int host_fd, Terminal::Complete &terminal, ServerConnection &
|
|||||||
/* Tell child to start login session. */
|
/* Tell child to start login session. */
|
||||||
if ( !child_released ) {
|
if ( !child_released ) {
|
||||||
if ( swrite( host_fd, "\n", 1 ) < 0) {
|
if ( swrite( host_fd, "\n", 1 ) < 0) {
|
||||||
perror( "child release" );
|
err( 1, "child release" );
|
||||||
_exit( 1 );
|
|
||||||
}
|
}
|
||||||
child_released = true;
|
child_released = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user