How to find the bundle identifier from a known PID?

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

+5
source share
2 answers

Here's a method that works in 10.2 and later: First call GetProcessForPIDto turn pid into ProcessSerialNumber. Then call ProcessInformationCopyDictionaryto get the package id. (Added: these functions are deprecated in OS 10.9. I don’t know if they still exist in the SDK 10.10.)

+4
source

I found an answer that only works with 10.6:

[[NSRunningApplication runningApplicationWithProcessIdentifier:pid] bundleIdentifier]

+6
source

All Articles