Re: Re: Log and locking

From: Date: Thu, 19 Sep 2002 11:52:39 +0000
Subject: Re: Re: Log and locking
References: 1 2  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-9198@lists.php.net to get a copy of this message
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. Kristian -- http://www.amazon.de/exec/obidos/wishlist/18E5SVQ5HJZXG

« previous php.pear.dev (#9198) next »