delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/01/22/11:44:28

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
X-Authentication-Warning: slinky.cs.nyu.edu: pechtcha owned process doing -bs
Date: Wed, 22 Jan 2003 11:44:13 -0500 (EST)
From: Igor Pechtchanski <pechtcha AT cs DOT nyu DOT edu>
Reply-To: cygwin AT cygwin DOT com
To: Gael Mulat <Gael DOT Mulat AT polyspace DOT com>
cc: cygwin AT cygwin DOT com
Subject: Re: Bug in rm -r with locked files
In-Reply-To: <3E2E5EEA.3000606@polyspace.com>
Message-ID: <Pine.GSO.4.44.0301221139220.23429-100000@slinky.cs.nyu.edu>
Importance: Normal
MIME-Version: 1.0

On Wed, 22 Jan 2003, Gael Mulat wrote:

>
>
> Gael Mulat wrote:
>
> >    Hi,
> >
> >    This is a bug report about rm (package fileutils, version 4.1-1) on W2K.
> >
> >    Test case: take 2 cygwin shells.
> > shell 1:
> >    mkdir /tmp/directory
> >    vi /tmp/directory/file
> >
> > shell 2:
> >    /bin/rm -rf /tmp/directory
> >
> >    The shell2 doesn't manage to remove the directory and goes into an
> > infinite loop, taking 100% of the CPU.
> >    All is then OK if we go out of vi in the shell1.
> >
> >    Doing the same thing (deleting the directory) directly in Windows
> > produces an error message: "cannot delete directory: Access is denied.
> > The source file may be in use" and we can notice in the directory a
> > file named .file.swp that is also visible under Cygwin with ls -la.
> >
> >    The example I have just given uses vi, but it is the same with all
> > processes that open the file, as W2K puts a lock on it.
> >
> > Gael Mulat
> >
>     OK. If I summurize all that has been said, this problem is
> well-known but has no solution in a near future.
>
>     But a workaround would be very useful for people (me and Brian
> Kelly, for instance) who use plenty of rm -rf in cross-platform shell
> scripts.
>
>     Thanks to Shankar Unni, I have mine: I didn't noticed that only rm
> -rf had the trouble, and not rm -r.
>
>     So my workaround will be to replace all the '/bin/rm -rf dir' by
> 'chmod -R +w dir; /bin/rm -r dir'. The semantic is not exactly the same
> (especially on write-protected directories), but that will allow my
> scripts to work well...
>
>     Thanks everybody.
> Gael.

A suggestion:

'/bin/find dir -depth -exec /bin/chmod +w {} \; -exec /bin/rm -r {} \;'
might work, and will only parse the tree once...  It will invoke chmod and
rm multiple times, though, but that's a tradeoff.
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha AT cs DOT nyu DOT edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor AT watson DOT ibm DOT com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

Oh, boy, virtual memory! Now I'm gonna make myself a really *big* RAMdisk!
  -- /usr/games/fortune


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