public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: find command seems to lock files
Date: Mon, 19 Aug 2019 14:26:00 -0000	[thread overview]
Message-ID: <20190819141321.GO11632@calimero.vinschen.de> (raw)
In-Reply-To: <609c28ca-07da-f150-139b-267448ede826@cs.umass.edu>

[-- Attachment #1: Type: text/plain, Size: 1854 bytes --]

On Aug 19 10:06, Eliot Moss wrote:
> On 8/19/2019 10:03 AM, Corinna Vinschen wrote:
> > On Aug 19 14:33, Morten Kjærulff wrote:
> > > Hi,
> > > 
> > > I have an application which constantly:
> > > creates a file
> > > do some processing
> > > deletes the file
> > > 
> > > One way to monitor if the application has crashed, is to check the age of
> > > the file, so I made a script that:
> > > 
> > > find //$server/d$/dir/subdir*/subsubdir -name 'thefile' -printf '%A+\n'
> > > 
> > > subdir* will be subdir1 subdir2 ...
> > > under subsubdir there will be dirA, dirB, ... and under those, thefile may
> > > exist.
> > > 
> > > Problem is that it seems this command locks thefile, as the application
> > > sometimes can't delete it.
> > > 
> > > Could this be true?
> > 
> > Cygwin does not actually lock anything except in very rare
> > circumstances.  Your problem is more likely triggered by a realtime
> > virus scanner.
> 
> I was wondering, though, whether the parent directory would
> be non-delete-able while find has the directory open for scanning.

Usually yes.  Cygwin moves the entire directory into the recycler in
case it's a local dir.  That works even if a file is blocking the
dir from deletion.

> If the application in question creates and deletes the parent
> directory, as well as the leaf file, then things would be left
> around unexpectedly.

The question was just if the file is locked.

> So would use of find trigger a virus scanner, which in turn might
> hold on to the file and prevent its deletion?

That's how some realtime scanners work.  They have hooks in the file API
and if some other process opens a file these scanners open the file as
well, typically without FILE_SHARE_DELETE, which Cygwin uses by default.


Corinna

-- 
Corinna Vinschen
Cygwin Maintainer

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2019-08-19 14:13 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-19 12:49 Morten Kjærulff
2019-08-19 14:06 ` Corinna Vinschen
2019-08-19 14:13   ` Eliot Moss
2019-08-19 14:26     ` Corinna Vinschen [this message]
2019-08-19 14:41       ` Morten Kjærulff
2019-08-19 15:03         ` Eliot Moss
2019-08-19 17:05         ` Andrey Repin
2019-08-19 17:21           ` Andrey Repin
2019-08-19 17:41           ` Morten Kjærulff
2019-08-19 18:52             ` Eliot Moss
2019-08-19 19:43           ` Greywolf
2019-08-21 19:53           ` L A Walsh
2019-08-26  1:57 ` Chris Wagner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190819141321.GO11632@calimero.vinschen.de \
    --to=corinna-cygwin@cygwin.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).