fix select usage

This commit is contained in:
2026-08-05 12:03:22 +03:00
parent 6f11eeb895
commit 9da2d4fdb3
+5 -2
View File
@@ -89,12 +89,15 @@ bool PIWaitEvent::wait(int fd, CheckRole role) {
FD_SET(pipe_fd[ReadEnd], &(fds[CheckRead])); FD_SET(pipe_fd[ReadEnd], &(fds[CheckRead]));
FD_SET(fd, &(fds[CheckExeption])); FD_SET(fd, &(fds[CheckExeption]));
if (fd_index != CheckExeption) FD_SET(fd, &(fds[fd_index])); if (fd_index != CheckExeption) FD_SET(fd, &(fds[fd_index]));
int sr = ::select(nfds, &(fds[CheckRead]), &(fds[CheckWrite]), &(fds[CheckExeption]), nullptr); int sr = -1;
do {
sr = ::select(nfds, &(fds[CheckRead]), &(fds[CheckWrite]), &(fds[CheckExeption]), nullptr);
} while (sr < 0 && errno == EINTR);
int buf = 0; int buf = 0;
while (::read(pipe_fd[ReadEnd], &buf, sizeof(buf)) > 0) while (::read(pipe_fd[ReadEnd], &buf, sizeof(buf)) > 0)
; ;
// piCout << "wait result" << sr << FD_ISSET(fd, &(fds[CheckExeption])) << FD_ISSET(fd, &(fds[fd_index])); // piCout << "wait result" << sr << FD_ISSET(fd, &(fds[CheckExeption])) << FD_ISSET(fd, &(fds[fd_index]));
if (sr == EBADF || sr == EINTR) return false; if (sr < 0) return false;
if (FD_ISSET(fd, &(fds[CheckExeption]))) return true; if (FD_ISSET(fd, &(fds[CheckExeption]))) return true;
return FD_ISSET(fd, &(fds[fd_index])); return FD_ISSET(fd, &(fds[fd_index]));
#endif #endif