MCPcopy Create free account
hub / github.com/DFHack/dfhack / read_char

Method read_char

library/Console-posix.cpp:218–241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216 }
217 private:
218 bool read_char(unsigned char & out)
219 {
220 FD_ZERO(&descriptor_set);
221 FD_SET(STDIN_FILENO, &descriptor_set);
222 FD_SET(exit_pipe[0], &descriptor_set);
223 int ret = TMP_FAILURE_RETRY(
224 select (std::max(STDIN_FILENO,exit_pipe[0])+1,&descriptor_set, NULL, NULL, NULL)
225 );
226 if(ret == -1)
227 return false;
228 if (FD_ISSET(exit_pipe[0], &descriptor_set))
229 return false;
230 if (FD_ISSET(STDIN_FILENO, &descriptor_set))
231 {
232 // read byte from stdin
233 ret = TMP_FAILURE_RETRY(
234 read(STDIN_FILENO, &out, 1)
235 );
236 if(ret == -1)
237 return false;
238 return true;
239 }
240 return false;
241 }
242
243 public:
244 void print(const char *data)

Callers

nothing calls this directly

Calls 1

readFunction · 0.85

Tested by

no test coverage detected