closedir(3) handling NULL

Garrett Wollman wollman at
Fri Jan 24 20:28:14 UTC 2014

<<On Sat, 25 Jan 2014 07:08:33 +1100 (EST), Bruce Evans <brde at> said:

> On Fri, 24 Jan 2014, Garrett Wollman wrote:
>> "may fail" has a very specific meaning in the "ERRORS" section: if the
>> implementation detects the condition described, it must use the
>> specified error number.

> That doesn't quite do it.  Detection of the error for closing a closed fd
> is still not required, unlike for fclose().

That is correct.  If the implementation detects this condition and
returns an error, it must indicate [EBADF].  But it need not detect
that condition, even if that will prevent it from performing the
function, and in that case, the function's behavior is unspecified.
Since there are no "shall"s involved, no conformance distinction can
be made between two implementations, one of which detects an invalid
stream and indicates [EBADF], and the other of which does not detect
an invalid stream but turns your computer into a frog.


More information about the freebsd-standards mailing list