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

2010-09-10 Thread Corinna Vinschen
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



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

2010-09-10 Thread Corinna Vinschen
On Sep 10 21:22, jurri...@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 0xC043
 
 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



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

2010-09-10 Thread Conway, Timothy
 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...)?

fuser


73,
Tim Conway
JBS USA | 1770 Promontory Ci | Greeley, CO 80634| USA
Direct: 970-506-7998  | Fax: 970.336.6195
email: timothy.con...@jbssa.com
JBS Server Team

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



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

2010-09-10 Thread jurriaan
 However, the workaround was missing a break from the loop, if the
 sharing violation persists.  I fixed that in CVS.
 
I do love open source software like this - fixes on a friday night.

I'm not sure if I'm ready to use CVS on a production system, but thanks
a lot!

Kind regards,
Jurriaan
-- 
Never use etc. -- it makes people think there is more where
 there is not or that there is not space to list it all, etc.


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