This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: find command seems to lock files


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: signature.asc
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]