Yup, that's the culprit. You are zeroing the file before obtaining the flock, thus possibly stomping on someone else's read or write.open(MFILE, ">$completeadd") || die "file open failed: $!\n"; flock(MFILE, LOCK_EX) || die "Lock failed: $!";
Either use File::CounterFile, or read my columns that use flock for working examples.
-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.
In reply to •Re: Safe Counter Follow Up
by merlyn
in thread Safe Counter
by Gorby
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |