Article 6401 of comp.lang.perl:
Xref: feenix.metronet.com comp.lang.perl:6401
Path: feenix.metronet.com!news.utdallas.edu!wupost!howland.reston.ans.net!spool.mu.edu!news.clark.edu!netnews.nwnet.net!news.uoregon.edu!gaia.ucs.orst.edu!ruby.oce.orst.edu!tardis.co.uk!bill
From:
[email protected] (William Hails)
Newsgroups: comp.lang.perl
Subject: Re: For SVR4 implementations, could perl use lockf rather than flock?
Date: Mon, 4 Oct 93 10:32:43 BST
Organization: Perl-Users Mail2News gateway
Lines: 31
Message-ID: <
[email protected]>
NNTP-Posting-Host: ruby.oce.orst.edu
Originator:
[email protected]
[email protected] (Tom Christiansen):
> >From the keyboard of
[email protected]:
> :Hi Perl gurus,
> :
> : I just got perl to run on Tandem's SVR4 UNIX implementation. One thing not provided
> :in SVR4 is flock(he said sheepishly), but file record locking does get provided through the
> :system call lockf(). Has anybody given thought to providing support for the perl function
> :flock using lockf? Thanks in advance for any direction you folks might have to give....
> Probably you can go through fcntl() to get at it.
> --tom
Here's an example:
open(LOCKFILE, ">>/usr/sysop/etc/menulock") || die "cant open lockfile";
require('sys/fcntl.ph');
$lock = pack('s s l l s', &F_WRLCK, 0, 0, 0, 0);
fcntl(LOCKFILE, &F_SETLK, $lock) || die "another process has the lock";
It has the advantage over flock that the lock is network-wide.
===========================================================================
| Bill Hails <
[email protected]> | |
| C.L.I. Connect Ltd. | README: permission denied |
| 19, Quarry St., Guildford, Surrey | |
| GU1 3UY. Tel (UK) 0483 300 200 | |
===========================================================================