Re: [gtk-list] Re: Detecting multiple application instances
- From: Andrew Wood <ivarch cus umist ac uk>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Re: Detecting multiple application instances
- Date: Thu, 19 Aug 1999 19:01:50 +0100 (BST)
My first thought was to use IPC - isn't there some way of testing to see if
another program already holds a particular resource? Don't know enough about
IPC to be sure (never used it myself) but presumably it would mean that you
could open the same application on 2 machines sharing the same home
directory, which Netscape would (I imagine) break on due to the file already
existing.
Looking at the ipc(5) man page it looks like IPC_CREAT | IPC_EXCL could be
used as a sort of machine-specific "lock file". You could also use IPC to
cause the second, unwanted, process to message the first and tell it to open
a new window.
Just my 2p. ;)
- Andrew
On Thu, 19 Aug 1999, Daniel Solaz wrote:
> Use a lock file somewhere in the users home directory. Put the PID
> inside so other instances can check with kill() whether the lock is held
> by an existing process or has been left behind. Check the lock at the
> beginning of your program: open() can be used to atomically
> test-or-create the lock file. Destroy the lock you hold at exit.
> This is what netscape's communicator does. I've done it in some
> programs and works fine. I can email some code if you want.
> -Daniel
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]