From 62330a0b092c73966e333d467d8efbbb04a58434 Mon Sep 17 00:00:00 2001 From: Keith Winstein Date: Fri, 20 Apr 2012 20:38:27 -0400 Subject: [PATCH] Put the setsid() where it belongs --- src/frontend/mosh-server.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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" );