Subject: Re: poll(2) oddity
To: Jaromir Dolecek <jdolecek@netbsd.org>
From: Matthias Buelow <mkb@informatik.uni-wuerzburg.de>
List: tech-userlevel
Date: 07/08/2002 13:50:23
Jaromir Dolecek writes:
>This isn't portable of course - the fd is opaque int number,
>kernel can return to you e.g. 18278932 even if you have only
>descriptors 0, 1, 2 open. The fact that Unix returns consequent
>descripts number is implementation detail. Also, using your
>way, you always waste three slots (0, 1, 2).
That is not true. A standards-conforming open(2) is required
to return the lowest available file descriptor (and that's also
how it has been traditionally.) From IEEE Std 1003.1-2001 (SUSv3):
The open() function shall return a file descriptor for the
named file that is the lowest file descriptor not currently
open for that process.
--mkb