Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Is it always necessary to lock a text file?

by Anonymous Monk
on Jun 24, 2000 at 14:39 UTC ( #19715=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I read the same text file from many pages, but only for read. Must the text file always be locked for security?

Originally posted as a Categorized Question.

  • Comment on Is it always necessary to lock a text file?

Replies are listed 'Best First'.
Re: Is it always necessary to lock a text file?
by lhoward (Vicar) on Jun 24, 2000 at 16:52 UTC
    If you are only reading a file, you do not need to lock it. Locks are only important when writing to the file is involved.
Re: Is it always necessary to lock a text file?
by Anonymous Monk on Dec 18, 2000 at 21:38 UTC
    Locking the file is not necessary when reading only, and when writing only if there is a possibility of more than one write happening simultaneously (as in the case of a cgi script or multi-user environment) If you are the only person using your script, or if it is a standalone script that only runs on one machine, locking is not necessary.
Re: Is it always necessary to lock a text file?
by I0 (Priest) on Dec 18, 2000 at 22:28 UTC
    If the file is being written while you are reading, it may be neccesary to LOCK_SH to avoid reading an inconsistent partial update.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://19715]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (2)
As of 2021-04-21 04:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?