(svn r1188) -Fix: [Network] Fixed that CTRL+<key> could sometimes hang a dedicated
authortruelight
Mon, 20 Dec 2004 16:35:16 +0000
changeset 736 53618d1ade61
parent 735 5c8bacd9fa7e
child 737 ceb3dce50a37
(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.
dedicated.c
--- a/dedicated.c	Mon Dec 20 16:15:19 2004 +0000
+++ b/dedicated.c	Mon Dec 20 16:35:16 2004 +0000
@@ -65,8 +65,8 @@
 /* Signal handlers */
 static void DedicatedSignalHandler(int sig)
 {
-		_exit_game = true;
-		signal(sig, DedicatedSignalHandler);
+	_exit_game = true;
+	signal(sig, DedicatedSignalHandler);
 }
 #endif
 
@@ -97,6 +97,7 @@
 {
 	struct timeval tv;
 	fd_set readfds;
+	byte ret;
 
 	tv.tv_sec = 0;
 	tv.tv_usec = 1;
@@ -105,9 +106,9 @@
 	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 @@
 
 #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 @@
 #ifdef UNIX
 	signal(SIGTERM, DedicatedSignalHandler);
 	signal(SIGINT, DedicatedSignalHandler);
-	signal(SIGABRT, DedicatedSignalHandler);
+	signal(SIGQUIT, DedicatedSignalHandler);
 #endif
 
 	// Load the dedicated server stuff