quick way to find out if a file is in use by windows?

Corinna Vinschen corinna-cygwin@cygwin.com
Fri Sep 10 20:26:00 GMT 2010


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



More information about the Cygwin mailing list