*BSD News Article 76176


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!news.mel.connect.com.au!news.mira.net.au!vic.news.telstra.net!act.news.telstra.net!psgrain!usenet.eel.ufl.edu!news.mathworks.com!news-res.gsl.net!news.gsl.net!portc01.blue.aol.com!newsstand.cit.cornell.edu!news.acsu.buffalo.edu!dsinc!news.ee.vill.edu!ldn-news.law.vill.edu!not-for-mail
From: sapa47@source.isd.state.in.us (Raymond L. Gilbert)
Newsgroups: comp.lang.perl.misc,comp.unix.bsd.freebsd.misc
Subject: Re: 'vipw' Style File Locking in Perl
Date: 15 Aug 1996 00:23:00 -0500
Organization: State of Indiana
Lines: 23
Message-ID: <4uuc7k$jju@source.isd.state.in.us>
References: <320DE5D9.3FF1@tassie.net.au>
NNTP-Posting-Host: source.isd.state.in.us
Xref: euryale.cc.adfa.oz.au comp.lang.perl.misc:36596 comp.unix.bsd.freebsd.misc:25512

Thus it was recorded by the prophets, Brook@tassie.net.au said:
>So I am wondering if anyone has a script out there that can implement 
>file locking in the same way that 'vipw' does.
>
>IE:-		open file
>	     lock file
>      write out new file
>      replace new file with old
>      close file
>      unlock file

I apologize for being slightly off topic here, but we had a very
similar need on some of our Web servers running under SYSV based
systems.  Last week, I wrote a simple C program called lockf which
uses the SYSV version of BSD's flock() called lockf().  Starting with
SVR3, lockf() supports mandatory file locking by turning the SGID bit
on, but the group exec bit off.  lockf does exactly the steps listed
above that we're just now using with some of our CGI applicaions.  If
anyone's interested in the source & man page for it, drop me a line!
-- 
Raymond L. Gilbert           "...the present rule in computing the circle's  
pi@isd.state.in.us            area is entirely wrong..."                     
http://source.isd.state.in.us/pi         - Indiana House Bill No. 246, 1897