Re: How to detect already running application...
- From: "John (J5) Palmieri" <johnp redhat com>
- To: fredderic excite com
- Cc: gtk-app-devel-list gnome org
- Subject: Re: How to detect already running application...
- Date: Fri, 18 Mar 2005 09:00:42 -0500
There are a number of hacks to do this. gnome-volume-manager uses the
clipboard. NetworkManager uses D-Bus. I'm not sure what g-edit uses,
perhaps bonobo. Future looking D-Bus is the way to go. You basically
grab a name and when your app comes up a second time it will get an
error when trying to grab the name again. It can then send messages to
the first instance to tell it what to do.
--
J5
On Thu, 2005-03-17 at 20:42, Freddie Unpenstein wrote:
Hello peoples of the net...
I was wondering, if anyone has come across any reliable means to find an already running instance of your
application, and get it to present itself instead of starting a new one.
I've done it in a small program I rolled together quickly, by creating a pid file in /tmp. If the file
exists and contains a number, it attempts to send a SIGUSR1 to the pid contained therein and then quits.
If not, it starts like usual. On reciept of a SIGUSR1, the program simply does a gtk_window_present() on
its main window.
This does have issues... For one, if the process doesn't close down properly, the pid file will remain,
and after some time a new process may well exist with the same pid, and the default handler for SIGUSR1 is
to kill the process. And secondly, my creation of the pid file isn't without a few race conditions. While
it's not a highly critical application, I would like to know if there's a safer and more reliable method of
doing this.
Fredderic
_______________________________________________
Join Excite! - http://www.excite.com
The most personalized portal on the Web!
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]