On Wed, Aug 25, 2010 at 11:50 AM, Paolo Bonzini <bonz...@gnu.org> wrote: > On 08/25/2010 11:48 AM, Erik Faye-Lund wrote: >> >> Actually, when I think of it - if any pipe got POLLHUP already, >> shouldn't poll just return right away? I mean, we already have an >> event, waiting in that case seems wrong to me. > > You would have to see what POSIX says. >
POSIX says to only wait if there hasn't been any signaled events: "If none of the defined events have occurred on any selected file descriptor, poll() shall wait at least timeout milliseconds for an event to occur on any of the selected file descriptors." After reading through the code again, I found that the code ATTEMPTS to do the right thing, but an unfortunate typo prevented it from happening: diff --git a/lib/poll.c b/lib/poll.c index aeb7a35..7c52cb6 100644 --- a/lib/poll.c +++ b/lib/poll.c @@ -505,7 +505,7 @@ poll (pfd, nfd, timeout) if (sought) handle_array[nhandles++] = h; if (pfd[i].revents) - wait_timeout = 0; + timeout = 0; } }