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 Message-Id: <5.1.0.14.2.20020406094553.02433da0@pop3.cris.com> X-Sender: rrschulz AT pop3 DOT cris DOT com Date: Sat, 06 Apr 2002 09:59:46 -0800 To: "Chris January" , From: Randall R Schulz Subject: Re: Infinite Loop In "rm -fr" When Busy File Encountered Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Chris, OK. Here's more information. Possibly even interesting information. I tried this as a test: % mkdir tstdir % cd tstdir % cat >tstdir & [1]+ Stopped cat >target % rm target # No complaint! % ls -l ls: target: Permission denied % rm target rm: cannot remove `target': Permission denied That was not quite what I expected, and, ignorant as I am about the Windows APIs, I cannot explain it. Now as it turns out, the case where I encountered this problem was when an errant non-Cygwin program (specifically, a Java program) was the culprit keeping the file open. I happened, presumably, due to incomplete clean-up by a tool plug-in executing within an IDE (jEdit). So, I wrote a little Java program to open a file for writing and then just pause, keeping the file open: import java.io.*; public class Writer { public static void main(String args[]) { if (args.length < 2) { System.err.println("Usage: Writer [ ... ]"); System.exit(1); } PrintWriter pw = null; try { pw = new PrintWriter(new FileWriter(args[0])); } catch (IOException ioEx) { System.err.println("Error opening \"" + args[0] + "\""); System.exit(2); } for (int argN = 1; argN < args.length; argN++) { pw.print(args[argN]); } Thread thisThread = Thread.currentThread(); for (;;) { try { thisThread.sleep(100 * 1000); } catch (InterruptedException iEx) { } } } } Now I do this: % mkdir subdir % java Writer subdir/target Now is the time In a separate Cygwin window: % cd tstdir % rm -fr subdir And the symptom is manifest: rm sits there, churning away, awaiting its death at the hands of a merciless signal. Randall Schulz Mountain View, CA USA At 09:26 2002-04-06, Chris January wrote: >> Greetings, >> >> I have encountered a problem in "rm" when used with the "-f" and "-r" >> options and a busy and hence unremovable file is encountered. >> >> When "rm -fr" encounters a busy and hence unremovable file, it goes into an >> infinite loop consuming as much CPU time as it can get until it is forcibly >> terminated. The error is completely repeatable as long as the file remains >> busy by virtue of being open in another program. >> >> The file system is NTFS and the mount is binmode. The system is Windows >> 2000 Pro with SP2 and security patches installed. >> >> This is an up-to-date Cygwin installation that is exhibiting no other >> anomalous behavior. >> >> In reference to the attached "cygcheck -rs" output, this happened on "C:" >> "/cygdrive/c" (reached via a symlink "/c -> /cygdrive/c"). > >I tried exhaustively to reproduce this (cygwin1.dll v1.3.10), but failed. > >Chris -- 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/