On Tue, 14 Dec 2004 11:03:56 +0800, Shu Hung (Koala) <[EMAIL PROTECTED]> wrote:
> Hello,
> I wrote a script which involved writing a file, which may als be writing
> by another script. To prevent crashes, I want to used the flock() function.
> 
> my question is:
> How do I check if a file is locked by other script or I simply can't read?

You try to lock the file, and check the return status of flock().

       flock FILEHANDLE,OPERATION
               Calls flock(2), or an emulation of it, on FILEHANDLE.  Returns
               true for success, false on failure. 

flock(FILEHANDLE, OPERATION) or die("Can't flock! $!\n");

Tor

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to