Re: File Descriptors & Linux 2.0

H. Peter Anvin (hpa@freya.yggdrasil.com)
27 Jun 1996 03:44:53 GMT


Followup to: <4qs1aq$4qv@picard.cistron.nl>
By author: miquels@cistron.nl (Miquel van Smoorenburg)
In newsgroup: linux.dev.kernel
>=20
> I just checked the Linux-2.0.0 kernel and the sys_select function nev=
er
> writes further in your fd_set than the nr_fds argument to select(). T=
his
> means that if NR_OPEN is increased, and the size of fd_set increases =
with it,
> it doesn't have consequences for older applications. The only thing i=
s that
> an old application can't handle a fd > 255 in a select() if one is pa=
ssed
> through fork()/exec() but I know of no applications that do this. So =
I think
> you can do this without trouble.
>=20
> If it's the other way around, and you try to pass a nr_fds > NR_OPEN =
to
> select() the kernel sys_select function will round it down to NR_OPEN
> quietly. So that doesn't cause trouble either.
>=20
> Somehow I get the feeling that sys_select() was coded with this alrea=
dy
> in mind..
>=20

How many applications do you know that actually check if the file
descriptor they get from the kernel is in the range 0 <=3D fd < NR_OPEN=
?
Most apps just use FD_SET() without any further checking.

-hpa
--=20
PGP public key available - finger hpa@zytor.com
I don't work for Yggdrasil, but they sponsor the linux.* hierarchy.
"The earth is but one country, and mankind its citizens." -- Bah=E1'u=
'll=E1h
Just Say No to Morden * Save Babylon 5: http://www.babylon5.com/cmp/sup=
port/