Here's some perl I wrote to implement file locking using the algorithm described in 'man 3 open', and as implemented by Lars Wirzenius in publib/lockfile.c. I have kept his function names. This has been but briefly and trivially tested, and will no doubt need tweaking and tuning. I believe this will work fine with nfs. Probably it should become a Perl5 object module. If you see any obvious errors or oversights, let me know. I am new to programming and to Perl, and would enjoy an exchange on these topics. Comments, ideas, and feedback will be greatly appreciated! Usage: $status = lockfile_create('./lockfilename'); # error testing... # do something with the file... $status = lockfile_remove('./lockfilename'); # error testing...
Attachment:
LockFile.pm
Description: Binary data
Karl M. Hegbloom <karlheg@inetarena.com> http://www.inetarena.com/~karlheg Portland, OR USA Debian GNU 1.2 Linux 2.0.29t