Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com To: cygwin AT cygwin DOT com X-Injected-Via-Gmane: http://gmane.org/ Path: not-for-mail From: Joe Buehler Newsgroups: gmane.os.cygwin Subject: Re: infinite loop in rm -fr (revisited) Date: Tue, 02 Jul 2002 16:35:36 -0400 Lines: 32 Message-ID: <3D220E98.2060209@hekimian.com> References: <3D21F96C DOT 50603 AT hekimian DOT com> <00d001c221fe$e5b242f0$0100a8c0 AT advent02> <3D220183 DOT 50700 AT hekimian DOT com> <018e01c22203$be757450$0100a8c0 AT advent02> NNTP-Posting-Host: hekimian.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1025642105 18582 206.205.138.10 (2 Jul 2002 20:35:05 GMT) X-Complaints-To: usenet AT main DOT gmane DOT org NNTP-Posting-Date: Tue, 2 Jul 2002 20:35:05 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.0.0) Gecko/20020530 X-Accept-Language: en-us, en Chris January wrote: > Possible solutions: > 1. rename the original file in the directory with a 'special name'. > e.g. > if deleting file1 and file1 is in use, rename to ...---file1---.... > Files matching this pattern would not be returned by readdir. > 2. rename the original file to a special 'holding' directory for pending > deleted files. > 3. in file access routines, pretend a file does not exist if it is present > in delqueue. (e.g. check could be added to path_conv::check). Doesn't cope > with another file being created with the same name. > > None of the above are ideal. 1 and 3 would fix some things, but it looks to me like #2 is the best, because the file is really deleted, as far as its former directory is concerned. So you don't have problems with Windows locking the directory down. But then there is the problem of under what conditions Windows will let you rename the file. I ran a test, and, curiously, the following script works, even though the "info" file is open when "mv" executes. #!/bin/bash trap "cd /; rm -fr /tmp/xxx.dir" 0 mkdir /tmp/xxx.dir exec >/tmp/xxx.dir/info mv /tmp/xxx.dir/info /tmp/info Joe Buehler -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/