Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com From: "John Pollock" To: Subject: dealing with removing open files Date: Tue, 2 Jan 2001 12:02:55 -0500 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 Importance: Normal I just noticed some strange behavior while using rm that i suspect is the fault of Windows and not of cygwin, but i thought i'd float it by here to make sure. In bash, if you're tailing a file called, say, "loop-log", and then while tailing it do "rm loop-log", rm does not complain that it wasn't able to remove the file, and in fact sets the exit status to "success". But strangeness ensues afterwards. So here's the file before doing the rm: BEAST$ ls -al loop-log -rw-r--r-- 1 curlbot Administ 16 Jan 2 11:53 loop-log BEAST$ cat loop-log blah blah Here's the rm (with another bash process doing the tail): BEAST$ rm loop-log BEAST$ No error message whatsoever. And yet here's the ls after doing the rm: BEAST$ ls -al loop-log -r-xr-xr-x 1 curlbot Administ 16 Jan 2 11:54 loop-log Still there? Well, the namespace is still being taken. But now the file is inaccessible: BEAST$ cat loop-log cat: loop-log: Permission denied If i then kill my tail, the file completely disappears and the namespace frees up. But until my tail process exits, i can't re-use the name "loop-log" in that directory. Is there a way to either a) get an errorlevel returned from rm if the file isn't utterly removed (i'm guessing not, since it does believe the file is deleted), b) delete the file in its entirety (i'm guessing not, since it's probably Windows that's marking the file as deleted but not removing it from the namespace), c) do something else? I'm hoping to avoid having to mv the file and reap it later, but i suspect i'm hampered by Windows limitations. Maybe detect somehow if the file is open, and delete it only if it's not? John -- Want to unsubscribe from this list? Check out: http://cygwin.com/ml/#unsubscribe-simple