Open thanhtungtvg95 opened 3 years ago
I am using function read_all() but process is blocking. I find this happen here: int read_bytes = read(fd, buf + rbytes, read_upto - rbytes);
Solution:
fd_set fds; struct timeval timeout; timeout.tv_sec = 3; /* timeout in secs */ timeout.tv_usec = 10000; FD_ZERO(&fds); FD_SET(fd, &fds); if (select(fd + 1, &fds, NULL, NULL, &timeout) > 0) { read_bytes = read(fd, buf + rbytes, read_upto - rbytes); } else { std::cout << "Time out" << std::endl; }
I am using function read_all() but process is blocking. I find this happen here: int read_bytes = read(fd, buf + rbytes, read_upto - rbytes);
Solution: