X-Recipient: archive-cygwin@delorie.com
X-Spam-Check-By: sourceware.org
Date: Fri, 10 Sep 2010 22:02:21 +0200
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: quick way to find out if a file is in use by windows?
Message-ID: <20100910200221.GJ16534@calimero.vinschen.de>
Reply-To: cygwin@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
References: <20100910114653.GA19315@onderneming10.xs4all.nl> <20100910145619.GA29101@calimero.vinschen.de> <20100910212215.GA32507@onderneming10.xs4all.nl>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
In-Reply-To: <20100910212215.GA32507@onderneming10.xs4all.nl>
User-Agent: Mutt/1.5.20 (2009-06-14)
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

On Sep 10 21:22, jurriaan@rivierenland.xs4all.nl wrote:
> > 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.
> > 
> Thanks for replying.
> I straced both mv and rm. The rm strace is at the bottom, below here
> first the mv strace. It only seems to hang, but the strace is filling up
> quickly with lots of lines like this continuously:
> 
>    63   77448 [main] mv 14716 rename: status 0xC0000043
> 
> Is this a status mv should fail on, or is Windows incorrectly returning
> a status that means 'repeat and retry by all means' ?

Oops.  I mixed up mv and rm, so my babble about unlink was off the
point.  Of course mv calls the rename function and the rename function
in fact has a loop which retries to rename a file or dir if a sharing
violation occurs.  The original idea of the retry loop was to workaround
a problem with some BLODAs - virus scanners - which block newly
generated files against deletion(*) for a short period of time while
checking them.  This breaks some applications which copy files by
creating a temporary filename and then rename the temp filename to the
target filename.

However, the workaround was missing a break from the loop, if the
sharing violation persists.  I fixed that in CVS.


Thanks,
Corinna


(*) On Windows a user needs delete permissions to rename a file.

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

