• 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: To find if a binary is being used/running
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: To find if a binary is being used/running


  • Subject: Re: To find if a binary is being used/running
  • From: Jens Alfke <email@hidden>
  • Date: Fri, 04 Oct 2013 10:53:47 -0700

On Oct 4, 2013, at 12:08 AM, Nick Rogers <email@hidden> wrote:

> Is this even possible?

Basically no. In Unix there is no connection from an executable file to a process running that file (or from _any_ file to a process that has that file open, really.) The most exhaustive solution is what the `lsof` and `ps` tools do, basically iterating over the kernel’s list of open files and running processes and looking for a match, which is expensive.

Unix tools often seem to use a strategy of creating a ‘pid’ file at some known location, which contains the process ID of the running instance of the tool. The tool has to write the file when it starts up, and be careful to delete it whenever it exits (including if it crashes or is killed.)

But I agree with Kyle, you should be using XPC or something similar to manage helper tasks.

—Jens
_______________________________________________

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: 
 >To find if a binary is being used/running (From: Nick Rogers <email@hidden>)

  • Prev by Date: Re: Doc Viewer in 5.0.1
  • Next by Date: Re: why isn't id<MyCellDelegate> an id?
  • Previous by thread: Re: To find if a binary is being used/running
  • Next by thread: Re: Updating provisioning profiles xCode 5
  • Index(es):
    • Date
    • Thread