i had one question i set out to be asked... namely... given file "F" (of
content "F"), simultaneously accessed by both users "1" and "2" (each of
them appending content "1" and content "2") , how do I end up with a file of
"F"+"1"+"2" and not just "F"+"1" or "F"+"2" or just "F" or even "foobar" ?
namely, how do I lock "fp $file" while "dirty_work(fp $file)" is being done
well use of flock() was suggested, but the documentation is not clear about
what exactly happens when I use flock() or how exactly I should use it for a
given instance. and, having found out that flock() is what I should use, a
few more questions arise.
I would really enjoy (and i think others might also enjoy) having all the
following questions answered verbosely or concisely as you see fit!
 Can I see an example code of flock() in action for a situation where two
users are going to possibly access the same file simultaneously, both of
them attempting to read and view its contents at once, and both of them
attempting to write their own appended and/or inserted (processed)
content -- simultaneously? in other words, an example of using flock() for
when dirty_work($file) must force one_user to wait while the_other_user is
doing dirty_work() ?
 your own preferred explanation for what happens on a hardware level when
flock is used ?
 your own preferred explanation for what happens on a software level when
flock is used ?
 situations when using flock() is not necessary ?
thank you Ahead Of Time for every piece of help you provide. this is the
first time i've had to leave the manual and ask somebody else for PHP help.
if you want to know, my problem is that i have designed a message forum that
stores all messages in a single file, maintaining hierarchy through a number
assigned to each entry. i need to insure that if two users access the file
at the same time to write their entries to it (even if the disk process
takes a total of 17 milliseconds) that what was intended to happen happens,
and not something messy and embarassing.
-gabriel arthur petrie
gabriel at arq.net
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!