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.
--------------
Charles Yeomans
_______________________________________________
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>
|