Mail Archives: cygwin/2006/01/27/17:30:58
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to Alex Riesen on 1/27/2006 11:26 AM:
>
> 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?
If the Austin Group API set 2 is approved
(http://www.opengroup.org/austin/mailarchives/ag/msg08954.html), you will
have mkdirat() that creates directories relative to an open file
descriptor on an existing directory; that would alleviate the
non-threadsafe use of chdir(). Until then, I don't know of ANY race-free
way to create a directory immediately followed by chdir() or open() that
guarantees that you used the same directory already made by mkdir().
Maybe if you call mkdir() restricting the access to just the user, then
open(O_NOFOLLOW), then fchmod(). What would be cool would be something
like giving valid semantics to open(O_CREAT|O_DIRECTORY) that acts as
mkdir(), but I doubt that will happen, either, thanks to current Linux
semantics (http://lkml.org/lkml/2005/9/24/8). Meanwhile, you can always
spawn mkdir(1) and have another process, with no restrictions on using
chdir(), do the directory creation for you.
If it is really that much of a problem for you, you should consider
raising a defect against the POSIX standard requesting that mkdir() be
guaranteed to fail with EEXIST on an existing directory, even if EROFS or
EACCES or EPERM would also otherwise apply.
- --
Life is short - so eat dessert first!
Eric Blake ebb9 AT byu DOT net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFD2p8Q84KuGfSFAYARAvITAKCHIEaVqyvIiEYnBDVM6Ihy2QyRmQCfZ+z0
p8JdUvzJYfWr3f/a2BV8dIw=
=+t2b
-----END PGP SIGNATURE-----
--
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/
- Raw text -