faqts : Computers : Programming : Languages : Perl : Common Problems

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

7 of 19 people (37%) answered Yes
Recently 3 of 7 people (43%) answered Yes

Entry

Is there a way to safely achieve multiple simultaneous writes to a file from different instances of a script i.e. different users?
How can I lock a file?

Jun 9th, 2000 06:52
unknown unknown, Per M Knutsen, Simon Cozens


perldoc -q lock:
Found in /usr/local/lib/perl5/5.6.0/pod/perlfaq5.pod
       How can I lock a file?
       Perl's builtin flock() function (see the perlfunc manpage
       for details) will call flock(2) if that exists, fcntl(2)
       if it doesn't (on perl version 5.004 and later), and
       lockf(3) if neither of the two previous system calls
       exists...