summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2004-12-20 16:35:16 +0000
committertruelight <truelight@openttd.org>2004-12-20 16:35:16 +0000
commit3d0cd51f276d19da28d315e1169f43a38c587f36 (patch)
treeb1fb2504db82a2ea629e45a5ba8139a1478c5dc7
parent9b237345d1b6de8e1e91d07772b0da7b64219a42 (diff)
downloadopenttd-3d0cd51f276d19da28d315e1169f43a38c587f36.tar.xz
(svn r1188) -Fix: [Network] Fixed that CTRL+<key> could sometimes hang a dedicated
server till enter was pressed. CTRL+D after a random key still does hang the dedicated server till enter is pressed.
-rw-r--r--dedicated.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/dedicated.c b/dedicated.c
index a5fd344aa..5197dd924 100644
--- a/dedicated.c
+++ b/dedicated.c
@@ -65,8 +65,8 @@ void DedicatedFork()
/* Signal handlers */
static void DedicatedSignalHandler(int sig)
{
- _exit_game = true;
- signal(sig, DedicatedSignalHandler);
+ _exit_game = true;
+ signal(sig, DedicatedSignalHandler);
}
#endif
@@ -97,6 +97,7 @@ static bool InputWaiting()
{
struct timeval tv;
fd_set readfds;
+ byte ret;
tv.tv_sec = 0;
tv.tv_usec = 1;
@@ -105,9 +106,9 @@ static bool InputWaiting()
FD_SET(STDIN, &readfds);
/* don't care about writefds and exceptfds: */
- select(STDIN+1, &readfds, NULL, NULL, &tv);
+ ret = select(STDIN + 1, &readfds, NULL, NULL, &tv);
- if (FD_ISSET(STDIN, &readfds))
+ if (ret > 0)
return true;
else
return false;
@@ -128,6 +129,9 @@ static void DedicatedHandleKeyInput()
#ifdef UNIX
if (InputWaiting()) {
+ if (_exit_game)
+ return;
+
fgets(input_line, 200, stdin);
// Forget about the final \n (or \r)
strtok(input_line, "\r\n");
@@ -167,7 +171,7 @@ static int DedicatedVideoMainLoop()
#ifdef UNIX
signal(SIGTERM, DedicatedSignalHandler);
signal(SIGINT, DedicatedSignalHandler);
- signal(SIGABRT, DedicatedSignalHandler);
+ signal(SIGQUIT, DedicatedSignalHandler);
#endif
// Load the dedicated server stuff