libc: only return requested events in poll()

Even if the underlying select() reports events, only report those
to the caller that were initially requested.
This commit is contained in:
Josef Söntgen 2017-05-18 17:06:40 +02:00 committed by Christian Helmuth
parent 22687bb10b
commit 028aeafabe
1 changed files with 2 additions and 2 deletions

View File

@ -89,10 +89,10 @@ poll(struct pollfd fds[], nfds_t nfds, int timeout)
fds[i].revents = 0;
if (fd == -1)
continue;
if (FD_ISSET(fd, &readfds)) {
if ((fds[i].events & POLLIN) && FD_ISSET(fd, &readfds)) {
fds[i].revents |= POLLIN;
}
if (FD_ISSET(fd, &writefds)) {
if ((fds[i].events & POLLOUT) && FD_ISSET(fd, &writefds)) {
fds[i].revents |= POLLOUT;
}
if (FD_ISSET(fd, &exceptfds)) {