[merge][#297831] use open/fchdir to save and restore cwd

John Arbash Meinel john at arbash-meinel.com
Thu Nov 20 15:23:09 GMT 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Martin Pool wrote:


+            while entry != NULL:
+                # Unlike most libc functions, readdir needs errno set to 0
+                # beforehand so that eof can be distinguished from
errors.  See
+                # <https://bugs.launchpad.net/bzr/+bug/279381>
+                while True:
+                    errno = 0;
+                    entry = readdir(the_dir)
+

^- We don't need the semicolon at the end of "errno = 0"  (I realize you
probably didn't put it there.)


...

+        if -1 != orig_dir_fd:
+            if -1 == fchdir(orig_dir_fd):
+                raise OSError(errno, strerror(errno))
+            if -1 == close(orig_dir_fd):
+                raise OSError(errno, strerror(errno))
+

^- Do we want to raise before we close the orig_dir_fd?

BB:approve

(I have confirmed that it works on cygwin at least.)

I'm a tiny bit concerned about the implications on cygwin, in that we
are holding open a file handle, but I'm not very concerned.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkklgN0ACgkQJdeBCYSNAAMZ6ACfblKjYVAllL4fsqztQ5gSt/wc
VMgAoJe+J84Ncm/MfZjXci9cCMWiiEX5
=6kwY
-----END PGP SIGNATURE-----



More information about the bazaar mailing list