From 00e10bc4a760150665436b17c50abf264f28d435 Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Mon, 11 Feb 2008 01:46:38 +0100 Subject: [PATCH] Don't intercept INT and QUIT signals, and use USR1 instead of QUIT for 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 | 2 +- gnushogi/init.c | 2 +- gnushogi/rawdsp.c | 6 ++---- xshogi/xshogi.c | 6 +++--- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/gnushogi/commondsp.c b/gnushogi/commondsp.c index 791cb30..0b677b1 100644 --- a/gnushogi/commondsp.c +++ b/gnushogi/commondsp.c @@ -2148,7 +2148,7 @@ InputCommand(char *command) #endif } - signal(SIGINT, TerminateSearch); + signal(SIGUSR1, TerminateSearch); } diff --git a/gnushogi/init.c b/gnushogi/init.c index 6e4cfce..ffef1f4 100644 --- a/gnushogi/init.c +++ b/gnushogi/init.c @@ -1271,7 +1271,7 @@ InitMain(void) if (XSHOGI) { - signal(SIGINT, TerminateSearch); + signal(SIGUSR1, TerminateSearch); TCmoves = 40; TCminutes = 5; diff --git a/gnushogi/rawdsp.c b/gnushogi/rawdsp.c index 1f9e4b3..fdc744a 100644 --- a/gnushogi/rawdsp.c +++ b/gnushogi/rawdsp.c @@ -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) { diff --git a/xshogi/xshogi.c b/xshogi/xshogi.c index 1d998d6..f6317dd 100644 --- a/xshogi/xshogi.c +++ b/xshogi/xshogi.c @@ -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; -- 1.7.0.4