kern/45291: kevent(2) ignores timeout if nevents == 0
gurney_j at efn.org
Sun Oct 19 11:11:44 PDT 2003
John Polstra wrote this message on Sun, Oct 19, 2003 at 10:38 -0700:
> On 19-Oct-2003 Boris Nikolaus wrote:
> > On Thu, Oct 16, 2003 at 10:09:58AM -0700, John-Mark Gurney wrote:
> >> events to wait for. In fact, after reading select's manpage, this
> >> misfeature isn't documented, and select really should return EINVAL
> >> if nfds is 0, and -1 is an invalid fd (which is the last fd that
> >> select is suppose to check)..
> > Select's manpage says, it checks all file descriptors from 0 to
> > nfds - 1. The set of whole numbers which are >= 0 and <= -1 is empty,
yes, but -1 is an invalid fd, so how can use that to put an upper bound
on a set when that number isn't valid to describe the numbers for the
set (the set of fds)?
> > so select has to check no descriptors and waits for the timeout. This
> > is exactly what select does, so this behaviour is implicitely
> > documented.
> > Changing select's behaviour as you suggest would break many software
I never suggested that..
> > as this behavious is often used, both in main loops (which have to
> > observe a set of file descriptors and timers and do not want to
> > handle the case "only timers left" in a special way) and explicitely
> > for sleeping (before microsleep/nanosleep have been invented, there
> > was no function for sleeping with resolution below seconds, so the
> > common way for sleeping in these cases was to call select with
> > nfds == 0).
> Boris is right about this, John-Mark. If you think otherwise then
> you really need to go read the code in a few real-world event loops.
do you mean select loops? or event loops? I've written enough code on
> They absolutely rely on this behavior of select. If anybody changed
> it they'd have a whole lot of broken programs on their hands. You may
> view it as a case of lazy programmers using the wrong system call for
> sleeping, but in fact it is just the proper and most sensible behavior
> for select to have at this boundary condition.
I never suggested that we change/fix select. I'm simply saying that
the manpage doesn't document the behavior everyone expects/sees... I
was simply playing devil's advocate on this subject.
John-Mark Gurney Voice: +1 415 225 5579
"All that I will do, has been done, All that I have, has not."
More information about the freebsd-bugs