don't listen on stdin if it's been closed

This commit is contained in:
Eric House 2013-06-10 06:15:36 -07:00
parent e6488ff8c1
commit c8f584dad2
3 changed files with 6 additions and 4 deletions

View file

@ -1743,7 +1743,9 @@ cursesmain( XP_Bool isServer, LaunchParams* params )
#endif
#ifdef USE_GLIBLOOP
cursesListenOnSocket( &g_globals, 0, handle_stdin );
if ( !params->closeStdin ) {
cursesListenOnSocket( &g_globals, 0, handle_stdin );
}
setOneSecondTimer( &g_globals.cGlobals );
# ifdef DEBUG
int piperesult =

View file

@ -1546,7 +1546,6 @@ main( int argc, char** argv )
XP_Bool isServer = XP_FALSE;
char* portNum = NULL;
char* hostName = "localhost";
XP_Bool closeStdin = XP_FALSE;
unsigned int seed = defaultRandomSeed();
LaunchParams mainParams;
XP_U16 nPlayerDicts = 0;
@ -1871,7 +1870,7 @@ main( int argc, char** argv )
break;
#endif
case CMD_CLOSESTDIN:
closeStdin = XP_TRUE;
mainParams.closeStdin = XP_TRUE;
break;
case CMD_QUITAFTER:
mainParams.quitAfter = atoi(optarg);
@ -2121,7 +2120,7 @@ main( int argc, char** argv )
srandom( seed ); /* init linux random number generator */
XP_LOGF( "seeded srandom with %d", seed );
if ( closeStdin ) {
if ( mainParams.closeStdin ) {
fclose( stdin );
if ( mainParams.quitAfter < 0 ) {
fprintf( stderr, "stdin closed; you'll need some way to quit\n" );

View file

@ -89,6 +89,7 @@ typedef struct LaunchParams {
XP_Bool duplicatePackets;
XP_Bool skipGameOver;
XP_Bool useMmap;
XP_Bool closeStdin;
#ifdef XWFEATURE_SEARCHLIMIT
XP_Bool allowHintRect;
#endif