cygwin-1.5.19-2: mkdir returns inconsistent errno

Alex Riesen fork0@users.sourceforge.net
Fri Jan 27 18:55:00 GMT 2006


Alex Riesen, Thu, Jan 26, 2006 17:21:21 +0100:
> > > > > This is highly unexpected, does not match linux behaviour
> > > > > (it returns EEXIST), and actually breaks git (git clone,
> > > > > creation of pathnames, to be precise).
> > > >
> > > > Then git has a bug.  Report it there.  To be portable
> > > > when making pathnames, you must first check
> > > > for directory existance rather than relying on an
> > > > errno of EEXIST to tell you the directory exists.
> > >
> > > How do you do it race-free?
> >
> > chdir().  If chdir() succeeded, then the directory existed,
> > regardless of the errno that mkdir() reported.
> > Take a look at gnulib's mkdir-p.c module:
> > http://cvs.savannah.gnu.org/viewcvs/gnulib/lib/mkdir-p.c?rev=1.5&root=gnulib&view=auto
> 
> Very interesting! Thank you for this and the other references.
> I'm given hope! :)

This was a bit prematurely. There is a big problem with this aproach:
it changes current directory of the process. So you can't really use
it in multithreaded or signalled environment.
So chdir is not a real solution. Is it really that hard to workaround
the problem in cygwin?


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list