Getting the responsible PID for an XPC process
Asked Answered
D

0

7

I'm trying to get the PID of the responsible process for an XPC process.

For example, Safari has a PID of 500, and is communicating with 3 instances of com.apple.WebKit.WebContent.xpc, with PIDs of 510, 520, and 530.

Activity Monitor.app seems to know that those 3 XPC processes are related to Safari. It claims the "Process Group" is "Safari Web Content".

But this has nothing to do with the real unix process group ID. The GPID is not Safari.app's. In fact, Safari.app isn't even the process parent - launchd is.

So the question is - how do I know the "responsible" PID (i.e. is it Safari or Mail) for a com.apple.WebKit.WebContent.xpc instance?

Deus answered 9/7, 2014 at 10:44 Comment(2)
Apps ask launchd via sockets (NSXPCConnection) to load an XPC process which is why it is listed as the parent process. I don't think it is possible to get the real initiator's identity due to the way they are launched in the first place. I could be wrong, though. You might be able to try your luck with NSXPCListener, and see if you can get mirrored the same messages that Safari/Mail sends to get the daemon to launch.Twentytwo
Activity Monitor.app does it, and so does Crash Reporter. Using an NSXPCListener and waiting for traffic for every single process is not viable.Deus

© 2022 - 2024 — McMap. All rights reserved.