That was my first thought, (hence my award-winning post above), but after reading the doc on flock, it appears that purpose of the flock isn't to stop the second program from opening the file - instead it stops the second program from obtaining the lock - the second program's flock(HANDLE, LOCK_EX) blocks until the first program issues flock(HANDLE, LOCK_UN).
The doc on flock shows a sequence much like that used by the OP, but without use of a spearate seamphore file.
Testing things very similar to the OP's code seems to work as expected. I don't see the issue.
--Bob Niederman, http://bob-n.comAll code given here is UNTESTED unless otherwise stated.
In reply to Re: Re: Mysterious Disapperance of file contents
by bobn
in thread Mysterious Disapperance of file contents
by Gorby
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |