This is the mail archive of the cygwin-developers@cygwin.com 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]

removing open files


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


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