[Wellington-pm] perl -f check failed
Grant McLean
grant at mclean.net.nz
Tue Jul 20 21:01:15 PDT 2010
On Wed, 2010-07-21 at 15:33 +1200, Jethro Carr wrote:
> On Wed, 2010-07-21 at 15:23 +1200, Grant McLean wrote:
> > > Essentially the script creates a number of text files whilst running and
> > > checks if any exist using -f - if they do, it knows to use a different
> > > name for the new file.
> >
> > That sounds like a classic race condition. If you check whether the
> > file exists before you create it then it's possible that another process
> > might create it between the time your check returns false and when you
> > create the file.
>
> thanks Grant,
>
> Good thinking, but one I've already checked - no other script was
> running at that stage. :-(
>
> (The script uses a lock file to enforce a single instance which I've
> confirmed by checking the logs for any evidence of a second process)
Then I'm afraid the next thing I'd suspect is a bug in your code
somewhere. I've never run into a situation where -f failed to see a
file.
I have run into all sorts of weird problems with file status when the
file being accessed is shared from a Windows server but since it's just
a local filesystem in your case, OS-level problems seem unlikely.
Cheers
Grant
More information about the Wellington-pm
mailing list