This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Unable to delete directory in Cygwin

mwoehlke wrote:
Eric Blake wrote:
Hash: SHA1

According to Gina Verlekar on 6/15/2006 3:53 AM:

I have implemented some changes in the linker code for some intermediate
processing. For that I need to create a temporary directory, generate
some intermediate in it, process those files by calling a function.
After processing of the intermediate files, I delete the intermediate
files and the temporary directory. While this logic works fine in the linux, the temporary directory does
not get deleted in cygwin.

Windows is not Linux, and will not allow users to delete in-use
directories (where a directory is considered in-use if it contains files,
or if any process is using that directory as its current working
directory), nor the clean deletion of files that are still open. POSIX
allows this behavior, and cygwin cannot change Window's implementation of
deletion semantics. Just because Linux behaves nicer doesn't mean that it
is portable to remove in-use directories. Fix your code to first close
all outstanding file handles before trying to remove the files, and then
the directory.

That said, cygwin does try to emulate linux, and if someone were to
contribute a patch that would allow cygwin to emulate directory deletion
if it knows that all open handles have also been scheduled for unlinking
at process end, then

Not a patch, but for the record, it looks like Interix solves this problem ( Maybe Cygwin could do something similar?

(And in case that link dies; apparently Interix has a special 'temp' directory where "unlinked" files are sent until their handles are all closed.)

If you take a look at the cygwin sources, you'll see that Cygwin does
something similar already.  This does not solve the problem for those
that want to unlink and immediately recreate the unlinked entry though...

-- Larry Hall RFK Partners, Inc. (508) 893-9779 - RFK Office 838 Washington Street (508) 893-9889 - FAX Holliston, MA 01746

Unsubscribe info:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]