- fd_set read_fds;
- struct timeval timeout;
-
- FD_ZERO(&read_fds);
- FD_SET(thread_quit_pipe[0], &read_fds);
- memset(&timeout, 0, sizeof(timeout));
- timeout.tv_sec = timeout_us / USEC_PER_SEC;
- timeout.tv_usec = timeout_us % USEC_PER_SEC;
-
- while (true) {
- ret = select(thread_quit_pipe[0] + 1, &read_fds, NULL, NULL,
- timeout_us != -1U ? &timeout : NULL);
- if (ret < 0 && errno == EINTR) {
- /* Retry on interrupt. */
- continue;
- } else {
- break;
- }
- }