Search the FAQ Archives

3 - A - B - C - D - E - F - G - H - I - J - K - L - M
N - O - P - Q - R - S - T - U - V - W - X - Y - Z
faqs.org - Internet FAQ Archives

comp.windows.x Frequently Asked Questions (FAQ) 7/7
Section - 195) How can I ensure that only one instance of my application is running?

( Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Part7 - Single Page )
[ Usenet FAQs | Web FAQs | Documents | RFC Index | Business Photos and Profiles ]


Top Document: comp.windows.x Frequently Asked Questions (FAQ) 7/7
Previous Document: 194) Why doesn't my multi-threaded X program work (sic) ?
Next Document: 196) How can I have two applications communicate via the X server?
See reader questions & answers on this topic! - Help others by sharing your knowledge

There are several mechanisms on the client-side you can use to ensure that
attempts to run multiple copies of an application are caught; you can use
them if you know that the second copy of the application will be invoked on
the same machine or the same network as the first or if you know that they
share a common view of a file-system. The common license-manager daemons
operate in this way.

A simple method that uses the X server as a conduit among several
applications which may be running on different machines and hence have only
the X server in common is for the first client to grab ownership of a
specially-named selection; the selection can be registered with the X
Registry to ensure its uniqueness. Subsequent invocations of the program can
check to see whether XGetSelectionOwner() for that selection returns an X
window; the program logic first checks to see whether or not it is a
duplicate, exiting if so, and otherwise sets the marker by asserting
ownership of the selection.

An alternative method, in which the first application writes a property to
the root window and subsequent invocations check for the existence of the
property as a sign that they are duplicate versions, fails both for being
easy to defeat and for tending to refuse to start up the first application
when it should do so -- if previous invocations crashed and the X server was
set not to remove the property when a client disconnects, the property may
have been left as a marker when it should have been removed.

[Thanks to Nicholas Young (youngn@logica.co.uk); 4/95]

Sample code implementing an alternate scheme is available from
	 http://www.wri.com/~cwikla/xcenter/singleLaunch

User Contributions:

Comment about this article, ask questions, or add new information about this topic:

CAPTCHA




Top Document: comp.windows.x Frequently Asked Questions (FAQ) 7/7
Previous Document: 194) Why doesn't my multi-threaded X program work (sic) ?
Next Document: 196) How can I have two applications communicate via the X server?

Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Part7 - Single Page

[ Usenet FAQs | Web FAQs | Documents | RFC Index ]

Send corrections/additions to the FAQ Maintainer:
faq%craft@uunet.uu.net (X FAQ maintenance address)





Last Update March 27 2014 @ 02:12 PM