🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.perl.misc
Article #251

lockfile

#251
From: Andreas Flick
Date: Tue, 17 Oct 1995 00:00
11 lines
1199 bytes
Hi,

I want a file to be opened only by one process at the same time.
I've done this in C before with something like this:
if (st=open(...,O_CREAT|O_EXCL,0) <= 0 )     (or >0 or ... well, I
                                              don't remember)
How can I do this from perl.
)yes,
flock(LOCK, $LOCK_EX+$LOCK_NB ) || die "error: $!\n";
works on machines where record locks are available
but this is something I can't rely on :-(
Technical Details
Message-ID: <4607ko$b93@rs18.hrz.th-darmstadt.de>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1043e7,ac9d9ed9fb5a957e,start
X-Google-Attributes: gid1043e7,public
X-Google-Thread: 1133f4,ac9d9ed9fb5a957e,start
X-Google-Attributes: gid1133f4,public
X-Google-Thread: fa0ae,ac9d9ed9fb5a957e,start
X-Google-Attributes: gidfa0ae,public
From: Andreas Flick <pvr@igd.fhg.de>
Subject: lockfile
Date: 1995/10/17
Message-ID: <4607ko$b93@rs18.hrz.th-darmstadt.de>
X-Deja-AN: 117682796
content-type: text/plain; charset=us-ascii
organization: Fraunhofer Inst. for Computer Graphics, Darmstadt, Germany
x-url: news://news.th-darmstadt.de/comp.lang.perl.misc
mime-version: 1.0
newsgroups: comp.lang.perl.misc,fj.lang.perl,de.comp.lang.perl
x-mailer: Mozilla 1.12 (X11; I; IRIX 5.3 IP19)