Re: [PHP4BETA] fopen() append contention
| From: | Faisal Nasim | Date: | Mon, 20 Mar 2000 06:38:15 +0000 |
| Subject: | Re: [PHP4BETA] fopen() append contention | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-12421@lists.php.net to get a copy of this message | ||
August,
: Have a quick question concerning fopen with append.
:
: With multiple scripts all writing to the same file, is there a risk that I
: end up overwriting data, even though I specify append?
:
: ie. Instance one opens file for append, file pointer set to end of file.
: Instance two already has an open copy for append, writes something.
Instance
: one writes something.
:
: The question is, can I avoid locking? comp.perl had a large discussion on
: this, and the feeling was yes. I'd prefer to avoid a locking solution, and
: am looking to be able to create log files along the lines of syslog which
of
: course doesn't requires locking.
Well, the locking solution exists in both Perl and PHP, actually its
borrowed
from a unix system commant, and the lock is handled by the kernel (doesn't
work on Win9X)...
Checkout the flock() command! Thats what you need.
Enjoy!
Faisal