Mail Archives: cygwin/2002/04/06/12:59:34
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 <outputFile> <string> [ ... ]");
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/
- Raw text -