There are two good reasons to use a lockfile. The first is that you may have operations involving multiple data sources and you want to maintain sync. The second is that you are both reading and writing to the same file and you want to avoid race conditions due to dropping the lock. But if everything is either just reading or just writing, then there is no race to worry about.
Also one warning on lockfiles. If you want to get atomic behaviour (if you don't know what that is then let your eyes glaze over and say "Yes") then you do not want to delete the lockfile. Else 2 processes can go to create it at once, one creates, the other overwrites with its new, both have filehandles to different files. (One is temporary.) The flocks both are captured at once, both think they have the lock. The timing has to be reasonably precise to do this, but it is worth knowing about.
In reply to Re (tilly) 2: CGI Form processing
by tilly
in thread CGI Form processing
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |