libc: bugfixes for minix's poll(3) wrapper

- clear "revents" fields even when the call times out;
- do not call FD_ISSET with a negative file descriptor number.

Change-Id: I7aeaae79e73e39aed127a75495ea08256b18c182
This commit is contained in:
David van Moolenbroek 2016-10-05 17:37:56 +00:00
parent 3ac58492b3
commit 6956dd2b51

View File

@ -57,6 +57,7 @@ poll(struct pollfd *p, nfds_t nfds, int timout)
highfd = -1;
for (i = 0; i < nfds; i++) {
p[i].revents = 0;
if (p[i].fd < 0)
continue;
if (p[i].fd >= FD_SETSIZE) {
@ -83,7 +84,8 @@ poll(struct pollfd *p, nfds_t nfds, int timout)
rval = 0;
for (i = 0; i < nfds; i++) {
p[i].revents = 0;
if (p[i].fd < 0)
continue;
if (FD_ISSET(p[i].fd, &rd))
p[i].revents |= POLLIN|POLLRDNORM|POLLRDBAND|POLLPRI;
if (FD_ISSET(p[i].fd, &wr))