diff options
author | John Hood <cgull@glup.org> | 2018-08-02 23:40:15 -0400 |
---|---|---|
committer | John Hood <cgull@glup.org> | 2018-08-03 15:16:55 -0400 |
commit | 3ea9e3e5a4c370243187e34c46f644ac5f2775f1 (patch) | |
tree | 2e0d90c431f341db8f3df7fc080444d1a130c3e5 /src | |
parent | 26143e9a6385845b4e052c4a720ad471bf20689e (diff) |
mosh-server: improve error logging
Also stop using _exit(), believed unnecessary now with proper stdio
flushing.
Diffstat (limited to 'src')
-rw-r--r-- | src/frontend/mosh-server.cc | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/frontend/mosh-server.cc b/src/frontend/mosh-server.cc index 567252f..1d48a54 100644 --- a/src/frontend/mosh-server.cc +++ b/src/frontend/mosh-server.cc @@ -451,8 +451,7 @@ static int run_server( const char *desired_ip, const char *desired_port, /* detach from terminal */ - fflush( stdout ); - fflush( stderr ); + fflush( NULL ); pid_t the_pid = fork(); if ( the_pid < 0 ) { 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 ); #endif /* HAVE_IUTF8 */ - fflush( stdout ); - fflush( stderr ); + fflush( NULL ); if ( isatty( STDOUT_FILENO ) ) { tcdrain( STDOUT_FILENO ); } if ( isatty( STDERR_FILENO ) ) { tcdrain( STDERR_FILENO ); } - _exit( 0 ); + exit( 0 ); } int master; @@ -596,15 +594,13 @@ static int run_server( const char *desired_ip, const char *desired_port, /* Wait for parent to release us. */ char linebuf[81]; if (fgets(linebuf, sizeof linebuf, stdin) == NULL) { - perror( "parent signal" ); - _exit( 1 ); + err( 1, "parent signal" ); } Crypto::reenable_dumping_core(); if ( execvp( command_path.c_str(), command_argv ) < 0 ) { - perror( "execvp" ); - _exit( 1 ); + err( 1, "execvp: %s", command_path.c_str() ); } } else { /* parent */ @@ -826,8 +822,7 @@ static void serve( int host_fd, Terminal::Complete &terminal, ServerConnection & /* Tell child to start login session. */ if ( !child_released ) { if ( swrite( host_fd, "\n", 1 ) < 0) { - perror( "child release" ); - _exit( 1 ); + err( 1, "child release" ); } child_released = true; } |