Re: Prevent to exec second copy of application
- From: "Liam R. E. Quin" <liam holoweb net>
- To: Andreas Volz <andreas volz brachttal net>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Prevent to exec second copy of application
- Date: Sun, 14 Nov 2004 21:53:53 -0500
On Sat, 2004-11-13 at 14:34 +0100, Andreas Volz wrote:
Am Sat, 13 Nov 2004 14:41:53 +0300 schrieb jakonda jakarta:
May be there is another algorithm to prevent starting second copy of
application in the same dipslay?
For X, you could check for the presence of another top-level
application window with the same name. You could have two
copies of the program running on different computers,
displaying to the same screen -- or two copies displaying
on two different screens -- and it's up to you to decide which
(if any) of those cases is a problem and why.
If it's because of access to a database or some other resource
you can't share, lock the resource. Make sure to do this in
such a way that you can recover if a program crashes or there
was a power failure. For example, include your process ID
(on Unix-like systems) in a lockfile, and contact the process
to see if it's another copy of the same program.
Many servers prevent multiple copies by binding to a known
network port -- e.g. 25 for sendmail, 6667 for IRC -- and
if they can't bind to the port they quit.
The file in /var/run is good for programs started by an
init.d service, as the service script can read the file
to shut the process down: the file contains the process
ID, and the service sends a signal.
Liam
--
Liam Quin, W3C XML Activity Lead, http://www.w3.org/People/Quin
Pictures from old books: http://www.holoweb.net/~liam/pictures/oldbooks/
IRC (chat) programs: www.ircreviews.org/clients/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]