Xref: utzoo news.software.nn:926 comp.unix.questions:25078 Path: utzoo!utstat!helios.physics.utoronto.ca!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!samsung!uunet!virtech!cpcahil From: cpcahil@virtech.uucp (Conor P. Cahill) Newsgroups: news.software.nn,comp.unix.questions Subject: Re: robust locking Message-ID: <1990Aug29.122152.1600@virtech.uucp> Date: 29 Aug 90 12:21:52 GMT References: <2320@cirrusl.UUCP> Reply-To: cpcahil@virtech.UUCP (Conor P. Cahill) Organization: Virtual Technologies Inc., Sterling VA Lines: 21 In article <2320@cirrusl.UUCP> dhesi%cirrusl@oliveb.ATC.olivetti.com (Rahul Dhesi) writes: >A very simple mechanism can be used to ensure that such race conditions >don't occur. Create a lock file that contains both process id and host >name. If a second process wants to create the same lock, it checks any >existing lock file. If the lock file exists, and the host name in it >is that of the current host, then the process id in it can be tested to >see if it is that of an existing process (and if not, that process >crashed and the lock file can be superseded). But if the host name in >the lock file is that of a different host, we refuse to supersede the >lock. But if you allow both processes to run on different hosts, you need to modify the other parts of rn that deal with the .newsrc and other related status/setup files. You will run into real problems when two processes try to write out different .newsrc files. -- Conor P. Cahill (703)430-9247 Virtual Technologies, Inc., uunet!virtech!cpcahil 46030 Manekin Plaza, Suite 160 Sterling, VA 22170