Re: To find if a binary is being used/running
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