Date: Wed, 03 Feb 1999 23:31:34 +0200 From: Sheldon Hearn <axl@iafrica.com> To: Robert Wall <rsw@vsat.net> Cc: security@FreeBSD.ORG Subject: Re: Perl and file locking Message-ID: <51845.918077494@axl.noc.iafrica.com> In-Reply-To: Your message of "Wed, 03 Feb 1999 12:29:07 CST." <Pine.BSF.3.96.990203122205.27616A-100000@bridge.millstream.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 03 Feb 1999 12:29:07 CST, Robert Wall wrote: > I noticed something interesting the other day - I'm writing a perl script > to add users to my master.passwd file, and I'm attempting to use exclusive > locks (flock filename, 2). During my test run of the script, another > program was accessing the file. My program paused and stuck until it > could get the exclusive lock for the file (~20 seconds), then finished > executing normally. Is this a bug, a feature, or just general weirdness? You need your lock attempt to be non-blocking: use Fcntl ':flock'; flock(HANDLE, LOCK_EX | LOCK_NB) or warn("Can't lock right now, will try again soon\n"); See flock(2) and perlfunc(1). Ciao, Sheldon. PS: Your question should really have gone to a perl-specific list, rather than a freebsd-specific list. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-security" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?51845.918077494>