I'm having trouble understanding the docs and annotations on flock().  I've 
got a script that needs to overwrite a data file's contents without letting 
Instance B of that script truncate the data file while Instance A is still 
writing new content to it.  How do other people do this?  It seems to me 
that if I fopen() in "w" or "w+" mode, then the file will be truncated 
before it can be determined whether there's a lock already in effect or the 
current instance can acquire a lock; but flock() requires a filepointer 
argument, so don't I *have* to fopen the file before going to flock()?  Or 
should I fopen first in "r" mode, acquire the lock, then re-open in "w" 
mode, counting on the lock to stay in effect even though it's a different 
file pointer?

I'd also be grateful if someone could clarify the difference between 
blocking and locking (i.e. "If you don't want flock() to block while 
locking, add LOCK_NB (4 prior to PHP 4.0.1) to operation.").

TIA

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to