From owner-freebsd-bugs@FreeBSD.ORG Sun Oct 19 10:38:45 2003 Return-Path: Delivered-To: freebsd-bugs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B6C1B16A4B3 for ; Sun, 19 Oct 2003 10:38:45 -0700 (PDT) Received: from blake.polstra.com (dsl081-189-066.sea1.dsl.speakeasy.net [64.81.189.66]) by mx1.FreeBSD.org (Postfix) with ESMTP id C3B8543F3F for ; Sun, 19 Oct 2003 10:38:44 -0700 (PDT) (envelope-from jdp@polstra.com) Received: from strings.polstra.com (dsl081-189-067.sea1.dsl.speakeasy.net [64.81.189.67]) by blake.polstra.com (8.12.9p2/8.12.9) with ESMTP id h9JHcaOH066693; Sun, 19 Oct 2003 10:38:36 -0700 (PDT) (envelope-from jdp@polstra.com) Message-ID: X-Mailer: XFMail 1.5.4 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <20031019130014.GA4033@fiesta.cs.tu-berlin.de> Date: Sun, 19 Oct 2003 10:38:36 -0700 (PDT) From: John Polstra To: Boris Nikolaus X-Bogosity: No, tests=bogofilter, spamicity=0.501781, version=0.14.5 cc: freebsd-bugs@freebsd.org cc: John-Mark Gurney Subject: Re: kern/45291: kevent(2) ignores timeout if nevents == 0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Oct 2003 17:38:45 -0000 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, > 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 > 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. 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. John