Put the setsid() where it belongs
This commit is contained in:
@@ -337,6 +337,10 @@ int run_server( const char *desired_ip, const char *desired_port,
|
|||||||
_exit( 0 );
|
_exit( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( setsid() < 0 ) {
|
||||||
|
perror( "setsid" );
|
||||||
|
}
|
||||||
|
|
||||||
fprintf( stderr, "\nmosh-server (%s)\n", PACKAGE_STRING );
|
fprintf( stderr, "\nmosh-server (%s)\n", PACKAGE_STRING );
|
||||||
fprintf( stderr, "Copyright 2012 Keith Winstein <mosh-devel@mit.edu>\n" );
|
fprintf( stderr, "Copyright 2012 Keith Winstein <mosh-devel@mit.edu>\n" );
|
||||||
fprintf( stderr, "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.\n\n" );
|
fprintf( stderr, "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.\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 ) {
|
if ( child == 0 ) {
|
||||||
/* child */
|
/* child */
|
||||||
|
|
||||||
setsid(); /* may fail */
|
|
||||||
|
|
||||||
/* reopen stdio */
|
/* reopen stdio */
|
||||||
stdin = fdopen( STDIN_FILENO, "r" );
|
stdin = fdopen( STDIN_FILENO, "r" );
|
||||||
stdout = fdopen( STDOUT_FILENO, "w" );
|
stdout = fdopen( STDOUT_FILENO, "w" );
|
||||||
|
|||||||
Reference in New Issue
Block a user