X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Date: Fri, 10 Sep 2010 16:56:19 +0200 From: Corinna Vinschen To: cygwin AT cygwin DOT com Subject: Re: quick way to find out if a file is in use by windows? Message-ID: <20100910145619.GA29101@calimero.vinschen.de> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: <20100910114653 DOT GA19315 AT onderneming10 DOT xs4all DOT nl> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20100910114653.GA19315@onderneming10.xs4all.nl> User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: 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 On Sep 10 11:46, Jurriaan wrote: > I use the mv command to clean up some directories filled with temporary > files. These may or may not be in use by windows. > > I used to detect them being in use by windows by mv failing. > > Now, mv is simply taking forever. > > I'm using cygwin 1.7.7(0.230/5/3), windows 2003 server 32 bits with all > updates on a local NTFS disk. > > I remember reading something about this changing in the last release, but > I can't find it in the archives anymore (searching for 'file in use' > didn't work out). > > Is there any way to detect if a file is in use by windows before > executing 'mv' (I really, really hope I don't have to use the > 'handle.exe' utility, which takes seconds for each file...)? > > Alternatively, could mv timeout somewhat earlier? I control-C'ed it > after 15 minutes, which is really too long already. mv does not timeout. The underlying unlink function checks if the file is in use and, if so, moves the file to the bin and sets the delete disposition so it will be deleted after the last process closes its handle to the file. If this fails, unlink silently gives up. The reason for the hang must be something else. Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Project Co-Leader cygwin AT cygwin DOT com Red Hat -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple