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:56:55 -0700
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <BFDAABE7 dot 76F1%Ed at Kleban dot com>

On Dec 30, 2005, at 8: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?

Just store the PID and then you can check if that PID still exists AND you can get the executable that the PID is running to see if it is the same one.
If its not then the lock file is old and can be deleted or ignored


_______________________________________________
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>