diff --git a/src/frontend/mosh-server.cc b/src/frontend/mosh-server.cc index 28480ce..2d90384 100644 --- a/src/frontend/mosh-server.cc +++ b/src/frontend/mosh-server.cc @@ -531,6 +531,13 @@ static int run_server( const char *desired_ip, const char *desired_port, warn_unattached( utmp_entry ); } + /* Wait for parent to release us. */ + char linebuf[81]; + if (fgets(linebuf, sizeof linebuf, stdin) == NULL) { + perror( "parent signal" ); + _exit( 1 ); + } + Crypto::reenable_dumping_core(); if ( execvp( command_path.c_str(), command_argv ) < 0 ) { @@ -592,6 +599,8 @@ static void serve( int host_fd, Terminal::Complete &terminal, ServerConnection & socklen_t saved_addr_len = 0; #endif + bool child_released = false; + while ( 1 ) { try { static const uint64_t timeout_if_no_client = 60000; @@ -713,6 +722,15 @@ static void serve( int host_fd, Terminal::Complete &terminal, ServerConnection & connected_utmp = true; } #endif + + /* Tell child to start login session. */ + if ( !child_released ) { + if ( swrite( host_fd, "\n", 1 ) < 0) { + perror( "child release" ); + _exit( 1 ); + } + child_released = true; + } } }