realbasic-nug
[Top] [All Lists]

Re: Mac OS X File Interlock

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Mac OS X File Interlock
From: Norman Palardy <npalardy at great-white-software dot com>
Date: Fri, 30 Dec 2005 09:58:08 -0700
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <BFDAABE7 dot 76F1%Ed at Kleban dot com> <f99012fbb0227099c524babd3cfc3172 at declareSub dot com>

On Dec 30, 2005, at 9:05 AM, Charles Yeomans wrote:


On Dec 30, 2005, at 10:18 AM, Ed Kleban wrote:

I need to implement a file interlock in MacOS X so that I don't have more than one application.... or more than one instance of that application that are running concurrently trying to open a given file at the same time. It's certainly easy enough for me to create for fileToUse.xxx an interlock file
named fileToUse.xxx.lock and then delete that .lock file when the
application using fileToUse.xxx closes stops using it or quits. But I'm
concerned about handling the case where the application crashes.

So my question is, is there anything useful I can store in
fileToUse.xxx.lock that other applications with a desire to use it can
easily check to see if the application that locked it is still alive and
running.   Perhaps some combination of the active process number and
application name associated with that process? Or is there some simple distinguishing value that a process has such as start date/time which is
less likely to be ambiguous in certain instances.

Is there a standard way of handling this in MacOS X?

No; see <http://developer.apple.com/technotes/tn/tn2037.html>. In a lock file, you could store the process ID. Then any other process could check it for validity.

You might want to check the PID and the executable IF this is a long running process.
PID's do get recycled


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>