Nick Moore
Nick Moore

Reputation: 15857

How to find Bundle Identifier from known PID?

I have the pid (process identifier) of an arbitrary running process. How can I find the bundle identifier (if any) of the associated application?

Upvotes: 5

Views: 2822

Answers (2)

JWWalker
JWWalker

Reputation: 22717

Here's a way that works in 10.2 and later: First call GetProcessForPID to turn the pid into a ProcessSerialNumber. Then call ProcessInformationCopyDictionary to get the bundle ID. (Added: these functions are deprecated in OS 10.9. I don't know if they still exist in the 10.10 SDK.)

Upvotes: 5

Nick Moore
Nick Moore

Reputation: 15857

I've found an answer which works on 10.6 only:

[[NSRunningApplication runningApplicationWithProcessIdentifier:pid] bundleIdentifier]

Upvotes: 7

Related Questions