Subject: Re: sys_select() EBADF bug
To: Tad Hunt <tad@entrisphere.com>
From: Greywolf <greywolf@starwolf.com>
List: tech-kern
Date: 11/14/2002 15:27:23
On Thu, 14 Nov 2002, Tad Hunt wrote:

# Currently, select will happily block forever if a bad fd is in the
# list and greater than fd_nfiles.  selscan() was already rewritten
# to use fd_getfile(), which correctly handles a fd beyond the end
# of the array.
#
# This way, if the process puts a fd > the number of open files in,
# it will still get an EBADF error back from select(2).

So what do you do in the case the proc.curproc.rlimit.nofiles.* gets
pushed below the selected fd?  It's still a valid descriptor.

Now, granted, it's a contrived edge case, but...what if?  Theoretically,
we might want to keep stdin, stdout, stderr opened, and maybe open a
socket or two, but decrease nofiles to 0 to prevent a given process from
(re)opening another file (call it paranoia).  What then on select()?

				--*greywolf;
--
NetBSD: No Worries!