Re: Re: Log and locking
| From: | Jon Parise | Date: | Thu, 19 Sep 2002 18:42:56 +0000 |
| Subject: | Re: Re: Log and locking | ||
| References: | 1 2 3 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-9227@lists.php.net to get a copy of this message | ||
On Thu, Sep 19, 2002 at 01:52:39PM +0200, Kristian Koehntopp wrote:
> On Tue, Sep 17, 2002 at 07:29:08PM +0100, Richard Heyes wrote:
> > if (!$this->_opened) {
> > $this->fp = fopen($this->filename, 'a');
> > + flock($this->fp, LOCK_EX);
> > + fseek($this->fp, 0, SEEK_END);
> > $this->_opened = true;
>
> Opening a file in append mode (a as the first character of
> mode) causes all subsequent write operations to this
> stream to occur at end-of-file, as if preceded by an
> fseek(stream,0,SEEK_END);
> call.
>
> Also, you do not need to lock. The mode "a" was created specifically to
> obviate the need for locking log files.
>
> See Stevens, "Advanced Programming In The UNIX Environment" for details and
> discussion.
Page 126 agrees with you. Thanks for pointing that out!
--
Jon Parise (jon@php.net) :: The PHP Project (http://www.php.net/)