delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/11/18/17:17:16

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
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 <jbuehler AT hekimian DOT 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 DOT A10374 AT ping DOT be> <20021116174458 DOT A10374 AT ping DOT be> <5 DOT 1 DOT 1 DOT 6 DOT 0 DOT 20021118155720 DOT 01abef50 AT pop DOT nycap DOT rr DOT com>
NNTP-Posting-Host: 64.47.34.2
Mime-Version: 1.0
X-Trace: main.gmane.org 1037657650 18549 64.47.34.2 (18 Nov 2002 22:14:10 GMT)
X-Complaints-To: usenet AT main DOT gmane DOT 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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019