Bug in rm -r with locked files

Randall R Schulz rrschulz@cris.com
Wed Jan 22 19:34:00 GMT 2003


At 08:44 2003-01-22, Igor Pechtchanski wrote:
>On Wed, 22 Jan 2003, Gael Mulat wrote:
>
> >     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


Igor,

I think we've drifted off the problem here. This isn't a issue of file 
modes interfering with file removal, its an interaction with window's 
"locking" of files that are in-use (open).

And as the discussion from last April showed, not all in-use states 
interfered with removal via Cygwin unlink(). While we were having 
trouble getting my original problem reproduced, I decided to write a 
Java program that opened a file and kept it open. Something about the 
way Java opened files triggered the problem where not all other uses did.

Perhaps it was just a Cygwin (non-interfering) vs. non-Cygwin 
(interfering) use of the file. I don't know. I don't know what was the 
exact diagnosis of the problem at the level of the Cygwin unlink code.

Chris January might know.

Randall Schulz 


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



More information about the Cygwin mailing list