• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Only one loaded executable...How ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Only one loaded executable...How ?


  • Subject: Re: Only one loaded executable...How ?
  • From: email@hidden
  • Date: Wed, 22 Jan 2003 21:31:02 +0100

On mercredi, janvier 22, 2003, at 08:38 PM, kubernan wrote:

I'm trying to find a elegant way to avoid the possibility
to launch my foundation application (no GUI) more than once.

1- My application provides NSNetServices. I could add a NSNetServiceBrowser
before, that detects if this service is already available on the local host. If yes, i'll
call exit(0).
2- I could use NSTask associates with some functions such as ps .... But what is
happening if the executable is renamed ?

More ideas ?

One:

Add this to your code:

CFDataRef myCallback(CFMessagePortRef local, SInt32 msgid, CFDataRef data, void *info)
{
}

int main(...)
{
CFMessagePortRef tMessagePortRef;
Boolean tFreeInfo=FALSE;

tMessagePortRef =CFMessagePortCreateRemote(kCFAllocatordefault, CFSTR("MyTool"));

if (tMessagePortRef!=NULL)
{
// Either the tool is not already running or we're so fast that the tool has not been launched yet

CFRelease(tMessagePortRef);

exit(0);
}

tMessagePortRef =CFMessagePortCreateLocal(kCFAllocatordefault, CFSTR("MyTool"),myCallback,NULL,& tFreeInfo);

// To be continued...

----8<------8<------8<-------

Compiled and coded with Mail.app so there might be bugs.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Only one loaded executable...How ?
      • From: Alex Rice <email@hidden>
References: 
 >Only one loaded executable...How ? (From: kubernan <email@hidden>)

  • Prev by Date: Re: Only one loaded executable...How ?
  • Next by Date: Re: Only one loaded executable...How ?
  • Previous by thread: Re: Only one loaded executable...How ?
  • Next by thread: Re: Only one loaded executable...How ?
  • Index(es):
    • Date
    • Thread