Is there any gtk-only way (not Gnome oriented) to do this ? I am looking for the same answer for my app, and the code needs to be working on Windows too.
Windows-only code is pretty simple using named mutex to act as kind of interprocess semaphore. But I am not sure if it can be that simple on Linux. Best regards, Miroslav Rajcic ----- Original Message ----- From: "John (J5) Palmieri" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Cc: <gtk-app-devel-list@gnome.org> Sent: Friday, March 18, 2005 3:00 PM Subject: Re: How to detect already running application... > 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 > > _______________________________________________ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list