How to detect already running application...
- From: "Freddie Unpenstein" <fredderic excite com>
- To: gtk-app-devel-list gnome org
- Subject: How to detect already running application...
- Date: Thu, 17 Mar 2005 20:42:44 -0500 (EST)
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!
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]