Utils.cpp 356 B

123456789101112131415161718
  1. #include <iostream>
  2. #include <poll.h>
  3. #include "Utils.h"
  4. int Utils::pollFileDescriptor(int fd, int timeoutMillis, const char* error) {
  5. struct pollfd fds;
  6. fds.fd = fd;
  7. fds.events = POLLIN;
  8. fds.revents = 0;
  9. int pollResult = poll(&fds, 1, timeoutMillis);
  10. if(pollResult == -1) {
  11. perror(error);
  12. }
  13. return pollResult;
  14. }