Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
To: cygwin@cygwin.com
X-Injected-Via-Gmane: http://gmane.org/
Path: not-for-mail
From: Joe Buehler <jbuehler@hekimian.com>
Subject: Re: infinite loop in rm
Date: Mon, 18 Nov 2002 17:16:01 -0500
Lines: 55
Message-ID: <3DD966A1.9040409@hekimian.com>
References: <20021116174458.A10374@ping.be> <20021116174458.A10374@ping.be> <5.1.1.6.0.20021118155720.01abef50@pop.nycap.rr.com>
NNTP-Posting-Host: 64.47.34.2
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: main.gmane.org 1037657650 18549 64.47.34.2 (18 Nov 2002 22:14:10 GMT)
X-Complaints-To: usenet@main.gmane.org
NNTP-Posting-Date: Mon, 18 Nov 2002 22:14:10 +0000 (UTC)
User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.1) Gecko/20020826
X-Accept-Language: en-us, en

William A. Hoffman wrote:

> I saw some mention of this problem here:
> http://www.cygwin.com/ml/cygwin/2002-07/msg00147.html
> 
> Is there a fix for this that works, or will be incorporated 
> into a future version of cygwin?  I looked in the FAQ and
> saw nothing about it.   I have some nightly scripts that clean
> some directories, and if I leave a shell open in one of the
> directories, the scripts just run forever trying to remove
> the directory.

I am using the following patch to unlink() on a version of Cygwin that
is several months old.  It does nothing unless there is a directory
named .cygdel at the root of the drive holding the file to be deleted.
In that case, it moves the file there before trying to delete it.

Make sure you make the directory mode 777 when you create it...

Works for me -- I think I posted this to the list but may be wrong.

Joe Buehler

Index: src/winsup/cygwin/syscalls.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/syscalls.cc,v
retrieving revision 1.214
diff -u -r1.214 syscalls.cc
--- src/winsup/cygwin/syscalls.cc	2 Jul 2002 03:06:32 -0000	1.214
+++ src/winsup/cygwin/syscalls.cc	8 Aug 2002 16:38:12 -0000
@@ -142,6 +142,23 @@
  	SetFileAttributes (win32_name, (DWORD) win32_name & ~FILE_ATTRIBUTE_READONLY);
      }

+  // attempt to rename before deleting
+  char *basename;
+  basename = strrchr(win32_name, '\\');
+  if (basename && *++basename) {
+    const char *rootdir = win32_name.root_dir();
+    if (rootdir) {
+      const char *s = strrchr(rootdir, '\\');
+      if (s && !s[1]) {
+	char newname[MAX_PATH + 12];
+	__small_sprintf(newname, "%s.cygdel\\%s", rootdir, basename);
+	if (MoveFile(win32_name.get_win32(), newname)) {
+	  win32_name.check(newname, PC_SYM_NOFOLLOW | PC_FULL);
+	}
+      }
+    }
+  }
+
    DWORD lasterr;
    lasterr = 0;
    for (int i = 0; i < 2; i++)




--
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/

