Detect EOF waiting for user input in xshogi and raw modes, and trigger exit.
authorYann Dirson <ydirson@free.fr>
Mon, 14 Oct 2013 19:34:04 +0000 (21:34 +0200)
committerYann Dirson <ydirson@free.fr>
Mon, 14 Oct 2013 19:34:04 +0000 (21:34 +0200)
No idea why the raw implementation of ExitShogi() did not call exit().
Even after detecting EOF, we were thrown into a tight loop...

gnushogi/commondsp.c
gnushogi/rawdsp.c

index 31dc80e..1f39b78 100644 (file)
@@ -1745,8 +1745,8 @@ InputCommand(char *command)
             {
                 s[0] = sx[0] = '\0';
 
-                while(!sx[0])
-                    (void)fgets(sx, 80, stdin);
+                while(!eof && !sx[0])
+                    eof = (fgets(sx, 80, stdin) == NULL);
             }
             else
             {
index 2109ca9..d3f3055 100644 (file)
@@ -204,6 +204,8 @@ Raw_ExitShogi(void)
 
     if (!nolist)
         ListGame();
+
+    exit(0);
 }