From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,a4200cba4e29ac X-Google-Attributes: gidfee84,public From: Timo Felbinger Subject: Re: Creating a lock file in C Date: 1999/05/06 Message-ID: #1/1 X-Deja-AN: 474649966 References: Content-Type: TEXT/PLAIN; charset=US-ASCII Organization: University of Potsdam Mime-Version: 1.0 Reply-To: Timo.Felbinger@quantum.physik.uni-potsdam.de Newsgroups: comp.unix.osf.osf1 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 Quantum Physics Group Institute of Physics University of Potsdam, Germany