From 204d2bea868bb30905f0656d4d6153f290c20a4d Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Wed, 16 Nov 2011 04:03:17 +0000 Subject: [PATCH] - added some extra error output on poll looping --- source/glest_game/main/main.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index 9e06b812f..3598e3175 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -3444,7 +3444,9 @@ int glestMain(int argc, char** argv) { while(program->isShutdownApplicationEnabled() == false && Window::handleEvent()) { if(isMasterServerModeEnabled == true) { #ifndef WIN32 - if(poll(cinfd, 1, 0)) + int pollresult = poll(cinfd, 1, 0); + int pollerror = errno; + if(pollresult) #else // This is problematic because input on Windows is not line-buffered so this will return // even if getline may block. I haven't found a good way to fix it, so for the moment @@ -3455,6 +3457,7 @@ int glestMain(int argc, char** argv) { if (WaitForSingleObject(h, 0) == WAIT_OBJECT_0) #endif { + getline(cin, command); cin.clear(); @@ -3462,6 +3465,15 @@ int glestMain(int argc, char** argv) { if(command == "quit") { break; } + +#ifndef WIN32 + if(pollresult < 0) { + printf("pollresult = %d errno = %d\n",pollresult,pollerror); + + cinfd[0].fd = fileno(stdin); + cinfd[0].events = POLLIN; + } +#endif } //printf("looping\n"); }