flock and file(myfile.txt)

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
If I want to use file(myfile.txt) and myfile.txt gets written to (flocked)  
frequently, what is the best approach?

Should I try to get a lock on myfile.txt before using file(myfile.txt)?

What I'm thinking is something like this:

   try a few times to pull the file into an array

   if you can, then do this

   if not, die

Other ideas?

Thanks in advance.  

Re: flock and file(myfile.txt)

Quoted text here. Click to load it

How about this:

$myfile = "/path/to/myfile.txt";
$timeout = 0;
while ($timeout < 10)
 if ($myarray = file($myfile))

Is this the right way to test file(myfile) ??

Site Timeline