diff --git a/src/frontend/mosh-server.cc b/src/frontend/mosh-server.cc index 112df7f..200535e 100644 --- a/src/frontend/mosh-server.cc +++ b/src/frontend/mosh-server.cc @@ -337,6 +337,10 @@ int run_server( const char *desired_ip, const char *desired_port, _exit( 0 ); } + if ( setsid() < 0 ) { + perror( "setsid" ); + } + fprintf( stderr, "\nmosh-server (%s)\n", PACKAGE_STRING ); fprintf( stderr, "Copyright 2012 Keith Winstein \n" ); fprintf( stderr, "License GPLv3+: GNU GPL version 3 or later .\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.\n\n" ); @@ -374,8 +378,6 @@ int run_server( const char *desired_ip, const char *desired_port, if ( child == 0 ) { /* child */ - setsid(); /* may fail */ - /* reopen stdio */ stdin = fdopen( STDIN_FILENO, "r" ); stdout = fdopen( STDOUT_FILENO, "w" );