Am 22.04.2015 um 21:55 schrieb Wietse Venema: > Wietse Venema: >> It was certainly new to me that readdir() requires the caller to >> reset errno before the readdir() call, if they need to distinguish >> between "no more information" and "error". > > I took some time to dig through old manpages at www.freebsd.org. > Generally, the description of readdir() results is vague. However, > The SunOS 4.1.3 manpage explicitly mentions that readdir() does not > change errno when it reaches the end of the directory. And while > SunOS 5.5.1 contains the usual vague text, SunOS 5.6 and later have > the explicit text. > > So I missed that. My apologies.
No worries. I have grown used to read standard documentation rather than, or in addition to, system-specific manual pages, to avoid portability pitfalls. Not all systems are fully compliant, but it avoids my being unaware that I am using system-specific extensions (GNUism or "Linuxism") or system-specific simplifications (such as readdir() not specifying errno on several systems). Several Linux distributions offer "manpages-posix" packages or similar that helps; "man 3p readdir" would get me a copy of the POSIX manual page rather than the GNU libc manual page that I get with "man readdir".