discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Detecting running application


From: Richard Frith-Macdonald
Subject: Re: Detecting running application
Date: Thu, 11 May 2006 13:58:09 +0100


On 11 May 2006, at 12:06, Chris B. Vetter wrote:

On 5/11/06, Richard Frith-Macdonald <richard@tiptree.demon.co.uk> wrote:
[...]
Assuming that you are only concerned about a single application ...

No. To ensure it's loaded only once in one single application wouldn't
be a problem, since I can check NSBundle-allBundles.

If you are concerned about multiple applications you really have a
problem ... you need to synchronize with bundle creation between apps.

Yes. A bundle can be loaded in (at least) three different ways:

1) An application can load it during startup using NSBundle- initWithPath:
2) GSAppKitUserBundles() can be set to load the bundle within the
2a) application's "domain" eg. Gorm = { GSAppKitUserBundles = (
/path/to/bundle ) }
2b) NSGlobalDomain

I simply want to make sure that, regardless of which of these three
cases is used, the bundle would be initialized only once.

All of them use [NSBundle-initWithPath:] eventually.

I've just tried to use DO, but apparently this will introduce a racing
condition if two applications are started within just a few seconds,
eg. during log in.

Not sure what you mean ... one (and only one) of the applications should be able to register with a particular name. If that's not the case, then DO name serving is thoroughly broken ... so I suspect any problem is with the logic in your code. If not, there is a bug we need to fix in the nameserver code.

I guess your apps could use [NSPortNameServer-registerPort:forName:]

The point is that in case (2) above, the applications wouldn't
necessarily be mine, so I have to do the check either in the bundle's
+initialize or -init ...

If the application is not yours, then obviously any solution in which you code a category to override -initWithPath: will not work since other applications won't contain the category. In fact I don't think there is any possible *general purpose* solution unless it's built into the gnustep libraries, and adding such a thing there seems perverse because I can't immediately see what use it would be to people generally. That could be my failing ... I still don't see what you actually want to achieve and why. Probably a special case solution is fine ... but I don't know what special case we are looking at...

I think I'm clear now that you only want one application to be able to load bundles , but is that one application per user, one per host, one per lan? Why is it important that only one application is able to load these bundles?

Which bundles are they? If they are all bundles containing code, and you control the bundles, or all of them have a principal class which inherits from a class you provide, presumably you could do whatever clever stuff you like in that class ... you couldn't stop the bundle being loaded, but you could completely change the way the bundle behaves in different applications.







reply via email to

[Prev in Thread] Current Thread [Next in Thread]