question about file locking (flock)...

They have: 447 posts

Joined: Oct 1999

ok, when is it necessary to lock a file?...

I assume if a file is used only for data, meaning scripts will read data from it but never write to it it does NOT need to be locked. Is this correct?

Now, assuming the above is correct, if a my script is accessing a file to write to, and other processes may need to read from or write to the file, i need to lock it, correct?

This is where im most confused, if my script needs to read from a file, but other processes may be writing to the file, i do not need to lock the file because the writing process will have already locked the file (see above) correct?

or just to be safe should i lock a file whenever its accessed, read or write?

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

http://www.cgi101.com/class/ch6/text.html may be of help.

Also www.irt.org has a tut on cgi security that I think covers this.

hth,

Suzanne

------------------
Zero Cattle
Suzanne
Tables DeMystified

They have: 1,587 posts

Joined: Mar 1999

irt.org is a nice site Suzanne. thx for the reference.

------------------
Thumbs up or down ratings of the best and worst ways to make $$$ on the net. CLICK 4 CASH! from Affiliate Programs and Ad Networks

Traffic-Website.com free traffic, affiliate programs, hosting, & domain names.
My Site got hacked, but i'm coming back?

They have: 447 posts

Joined: Oct 1999

thank you for the info, very helpful

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.