diff options
| author | Petr Mrázek | 2011-10-31 04:17:35 +0100 |
|---|---|---|
| committer | Petr Mrázek | 2011-10-31 04:17:35 +0100 |
| commit | 98cab0e9ad51eed4c04456f6f9ab888b33fb9ae4 (patch) | |
| tree | b09389219d9453f6e1a18e8a7fa7b44947c9e752 /library/Console-linux.cpp | |
| parent | 84e1a952056d1996d61a02c927017039db948487 (diff) | |
| download | dfhack-98cab0e9ad51eed4c04456f6f9ab888b33fb9ae4.tar.gz dfhack-98cab0e9ad51eed4c04456f6f9ab888b33fb9ae4.tar.bz2 dfhack-98cab0e9ad51eed4c04456f6f9ab888b33fb9ae4.tar.xz | |
Really fix linux Console.
Diffstat (limited to 'library/Console-linux.cpp')
| -rw-r--r-- | library/Console-linux.cpp | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/library/Console-linux.cpp b/library/Console-linux.cpp index 083d4197..d74c4804 100644 --- a/library/Console-linux.cpp +++ b/library/Console-linux.cpp @@ -143,22 +143,25 @@ namespace DFHack private: bool read_char(unsigned char & out) { - while(1) + FD_ZERO(&descriptor_set); + FD_SET(STDIN_FILENO, &descriptor_set); + FD_SET(exit_pipe[0], &descriptor_set); + int ret = TEMP_FAILURE_RETRY( + select (FD_SETSIZE,&descriptor_set, NULL, NULL, NULL) + ); + if(ret == -1) + return false; + if (FD_ISSET(exit_pipe[0], &descriptor_set)) + return false; + if (FD_ISSET(STDIN_FILENO, &descriptor_set)) { - while (select(FD_SETSIZE, &descriptor_set, NULL, NULL, NULL) < 0) - { - if(errno == EINTR) - continue; - return false; - } - if (FD_ISSET(STDIN_FILENO, &descriptor_set)) - { - // read byte from stdin - read(STDIN_FILENO, &out, 1); - return true; - } - if (FD_ISSET(exit_pipe[0], &descriptor_set)) + // read byte from stdin + ret = TEMP_FAILURE_RETRY( + read(STDIN_FILENO, &out, 1) + ); + if(ret == -1) return false; + return true; } } protected: |
