On Tue, Jun 25, 2013 at 11:34:03PM +0200, Armin Rigo wrote:

> Sorry, I don't follow you.  As far as I know the Linux man page is not
> clear about what occurs to errno if readdir() doesn't return NULL...

Exactly :) My reading of it is that readdir returns: NULL and sets errno if
an error occurred; NULL and doesn't change errno if end of directory was
reached; non-NULL and no guarantees about errno if it's half-way through
reading a directory and no errors occurred. I came to the conclusion that I
had to be defensive and do the following: errno must be set to 0 before
readdir; only if NULL is returned can errno be checked to see its value.

[When I read through the OpenBSD source, the implementation happens to define
that if non-NULL is returned, errno isn't fiddled about with (unless
getdirentries is buggy, which I didn't check!). The documentation does not
mention anything about this, so I think one has to assume that all bets are
off, particularly on other OS's.]

This all seems a big mess to me, but since I changed my code, I've had no
problems with readdir (on OpenBSD or Linux), so I assume my defensive action
was successful...


Laurie
-- 
Personal                                             http://tratt.net/laurie/
Software Development Team                                http://soft-dev.org/
   https://github.com/ltratt              http://twitter.com/laurencetratt
_______________________________________________
pypy-dev mailing list
pypy-dev@python.org
http://mail.python.org/mailman/listinfo/pypy-dev

Reply via email to