• 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: prevent multiple instances of a program
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: prevent multiple instances of a program


  • Subject: Re: prevent multiple instances of a program
  • From: Tito Ciuro <email@hidden>
  • Date: Wed, 11 May 2011 18:15:37 -0300

Hi Martin,

One way to do it is via flock():

http://developer.apple.com/library/mac/#documentation/darwin/reference/manpages/man2/flock.2.html

-- Tito

On May 11, 2011, at 6:04 PM, Dave DeLong wrote:

> There are a bunch of ways to do this, but the general principle is that when an instance of the app starts, it makes its presence known somehow (touching a file, broadcasting a distributed notification, vending a distributed object, etc).  Then when a second instance starts, it tries to find a previous instance (looking for the file, broadcasting a distributed notification and waiting for a response, connecting to a distributed object, etc).  If it finds one, it kills itself.
>
> Dave
>
> On May 11, 2011, at 2:02 PM, Martin Batholdy wrote:
>
>> Hi,
>>
>> My program consists of a menu item and is NSUIagent - so it is hidden in the Mac OS app-bar.
>>
>> Now what surprises me is that I am able to open several instances of this program.
>> Every time I click on the app-file a new symbol appears and I have a new instance of my program running.
>>
>> How can I prevent this?
>> (so that system-wide you can only have one instance of the program running)
>>
>> Is there a build-option in xCode for this?
>>
>>
>> thanks!_______________________________________________
>>
>> Cocoa-dev mailing list (email@hidden)
>>
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >prevent multiple instances of a program (From: Martin Batholdy <email@hidden>)
 >Re: prevent multiple instances of a program (From: Dave DeLong <email@hidden>)

  • Prev by Date: Re: QuickTime Player - like application
  • Next by Date: Re: prevent multiple instances of a program
  • Previous by thread: Re: prevent multiple instances of a program
  • Next by thread: Re: prevent multiple instances of a program
  • Index(es):
    • Date
    • Thread