On May 15, King, Jason said:

>>A rather clever way to emulate locking is to use mkdir() and rmdir().
>>
>>Although it requires you to create a lock file, it's atomic and safe.
>
>are you sure ? .. just because it constitutes one Perl statement doesn't
>mean that it's atomic .. I suspect mkdir has several steps internally
>
>if you're sure then can you please provide references to the atomicity of
>mkdir .. because it's a great find if it's truly atomic - many peopl believe
>there to be no atomic file locking operation on Win9x machines

Here are some references:

http://www.davin.ottawa.on.ca/archive/modperl/2000-09/msg00683.phtml
http://mail-index.netbsd.org/tech-security/1997/03/24/0010.html
http://mail.gnu.org/pipermail/info-cvs/2000-December/011597.html

They say that mkdir() is atomic ON A SERVER -- if you're on an NFS, all
bets are off.

The Perl Cookbook mentions the mkdir+rmdir locking scheme.  I think that's
a pretty safe bet.

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
Are you a Monk?  http://www.perlmonks.com/     http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc.     http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter.         Brother #734

Reply via email to