1 // SPDX-License-Identifier: GPL-2.0
2 #include <sys/select.h>
6 int read_with_timeout(int fd, char *buf, size_t count, long usec)
8 const long M = 1000 * 1000;
9 struct timeval tv = { usec / M, usec % M };
15 err = select(fd + 1, &fds, NULL, NULL, &tv);
18 if (FD_ISSET(fd, &fds))
19 return read(fd, buf, count);