This is the mail archive of the
cygwin-developers@cygwin.com
mailing list for the Cygwin project.
removing open files
- From: Joe Buehler <jbuehler at hekimian dot com>
- To: Cygwin Developers <cygwin-developers at cygwin dot com>
- Date: Wed, 26 Mar 2003 08:12:44 -0500
- Subject: removing open files
- Organization: Spirent Communications, Inc.
- Reply-to: jbuehler at hekimian dot com
The following script demonstrates a bug under NT -- the final rm goes
into an infinite loop because there is an open file in the directory
being removed.
#!/bin/bash
set -x
rm -fr /tmp/junk.dir
mkdir /tmp/junk.dir
# try to remove a directory containing an open file
rm -fr /tmp/junk.dir >/tmp/junk.dir/junk.file
I believe the only solution to this is to move files elsewhere before
they are deleted. As long as there is something open under a directory,
Windows appears to lock the directory, and it cannot be removed -- which
is not UNIX behavior, and will break programs that depend on UNIX
behavior.
I have a simple patch to fix this. It looks for a specially-named
directory at the root of the drive holding the file, and moves it there
before deleting the file. Any failures encountered (e.g. directory doesn't
exist) cause reversion to the current behavior.
Can we re-open the discussion on this and get a final fix into Cygwin?
--
Joe Buehler