Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* Creating a lock file in C
@ 1999-05-05  4:00 Michael Livingston
  1999-05-06  4:00 ` Timo Felbinger
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Livingston @ 1999-05-05  4:00 UTC (permalink / raw)


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.





^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Creating a lock file in C
  1999-05-05  4:00 Creating a lock file in C Michael Livingston
@ 1999-05-06  4:00 ` Timo Felbinger
  0 siblings, 0 replies; 2+ messages in thread
From: Timo Felbinger @ 1999-05-06  4:00 UTC (permalink / raw)



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





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1999-05-06  4:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-05-05  4:00 Creating a lock file in C Michael Livingston
1999-05-06  4:00 ` Timo Felbinger

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