Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: Timo Felbinger <timof@uranos.quantum.physik.uni-potsdam.de>
Subject: Re: Creating a lock file in C
Date: 1999/05/06	[thread overview]
Message-ID: <Pine.LNX.4.10.9905060932520.237-100000@uranos.quantum.physik.uni-potsdam.de> (raw)
In-Reply-To: Pine.GSO.4.10.9905052145100.27623-100000@mail.bcpl.net


On Wed, 5 May 1999, Michael Livingston wrote:

> I'm creating a lock file in C on Digital UNIX 4.0D.  I got the statement
> "open ( filename, O_WRONLY | O_CREAT | O_EXCL, 0644)" from a book on UNIX
> programming.  The book said that UNIX documentation implies that this will
> work, but does not explicitly state that it well.  Does anybody know if
> this will always allow only one process at a time to successfully create
> the lock file?  We have a multi-CPU system if that has an impact.
> 

If you are creating the lock file on a local file system, this call
should be atomic and either succeed and create the file, or fail if
the file already exists, independend of the number of CPUs. If the file
system is mounted from a remote server, this may not be guaranteed, so
you might want to make sure you create the lock file locally, to be on
the safe side.
-- 
Timo Felbinger   <Timo.Felbinger@quantum.physik.uni-potsdam.de>
Quantum Physics Group
Institute of Physics
University of Potsdam, Germany





      reply	other threads:[~1999-05-06  4:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-05-05  4:00 Creating a lock file in C Michael Livingston
1999-05-06  4:00 ` Timo Felbinger [this message]
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox