On Thu, May 06, 2010 at 02:48:32PM +0200, Joerg Sonnenberger wrote: > On Thu, May 06, 2010 at 08:51:29AM +0000, David Holland wrote: > > On Thu, May 06, 2010 at 08:14:08AM +0000, Jukka Ruohonen wrote: > > > Correct the discussion about return values: fileno() may fail and return > > -1. > > > Note that in such cases the NetBSD implementation does not set errno to > > > EBADF, hence diverging from the standard in this small detail. > > > > How is that not just a bug? > > -1 is a valid answer for not file-backed FILEs. I don't think it is an > error.
RETURN VALUE Upon successful completion, fileno() shall return the integer value of the file descriptor associated with stream. Otherwise, the value -1 shall be returned and errno set to indicate the error. ERRORS The fileno() function may fail if: [EBADF] The stream argument is not a valid stream, or the stream is not associated with a file. Isn't the above EBADF exactly what you are after? - Jukka.