Don't intercept INT and QUIT signals, and use USR1 instead of QUIT for
authorYann Dirson <ydirson@altern.org>
Mon, 11 Feb 2008 00:46:38 +0000 (01:46 +0100)
committerYann Dirson <ydirson@free.fr>
Sun, 29 Sep 2013 13:39:24 +0000 (15:39 +0200)
communication.

This braindead use of SIGINT causes problem when a frontend is
interrupted with Ctrl-C: if gnushogi is waiting for input, it would
enter a tight loop trying to read stdin, eating 100% CPU.

gnushogi/commondsp.c
gnushogi/init.c
gnushogi/rawdsp.c
xshogi/xshogi.c

index 791cb30..0b677b1 100644 (file)
@@ -2148,7 +2148,7 @@ InputCommand(char *command)
 #endif
     }
 
-    signal(SIGINT, TerminateSearch);
+    signal(SIGUSR1, TerminateSearch);
 }
 
 
index 6e4cfce..ffef1f4 100644 (file)
@@ -1271,7 +1271,7 @@ InitMain(void)
 
     if (XSHOGI)
     {
-        signal(SIGINT, TerminateSearch);
+        signal(SIGUSR1, TerminateSearch);
 
         TCmoves      = 40;
         TCminutes    = 5;
index 1f9e4b3..fdc744a 100644 (file)
@@ -311,8 +311,7 @@ Raw_help(void)
            TimeControl.moves[black], TimeControl.clock[black] / 100,
            TCadd/100, MaxSearchDepth);
 
-    signal(SIGINT, Raw_TerminateSearch);
-    signal(SIGQUIT, Raw_TerminateSearch);
+    signal(SIGUSR1, Raw_TerminateSearch);
 }
 
 
@@ -484,8 +483,7 @@ SetupBoard(void)
 void
 Raw_SearchStartStuff(short side)
 {
-    signal(SIGINT, Raw_TerminateSearch);
-    signal(SIGQUIT, Raw_TerminateSearch);
+    signal(SIGUSR1, Raw_TerminateSearch);
 
     if (flag.post)
     {
index 1d998d6..f6317dd 100644 (file)
@@ -7131,7 +7131,7 @@ void DisplayTitle(char *title)
 
 
 /* CHECKME: does this work?
- * This routine sends a SIGINT (^C interrupt) to gnushogi to awaken it
+ * This routine sends a SIGUSR1 to gnushogi to awaken it
  * if it might be busy thinking on our time.  This normally isn't needed,
  * but is useful on systems where the FIONREAD ioctl doesn't work since
  * on those systems the gnushogi feature that lets you interrupt its thinking
@@ -7159,11 +7159,11 @@ Attention(int pid)
         {
             if (xshogiDebug || localPlayer.appData.debugMode)
             {
-                fprintf(stderr, "Sending SIGINT to %s\n",
+                fprintf(stderr, "Sending SIGUSR1 to %s\n",
                         ((pid == firstProgramPID) ? "first" : "second"));
             }
 
-            (void)kill(pid, SIGINT); /* stop it thinking */
+            (void)kill(pid, SIGUSR1); /* stop it thinking */
         }
         break;