When I view processes in Activity Monitor's "All Processes, Hierarchical" view, it shows which processes launched other processes. For instance, if I have "Network" open inside "System Preferences", then when I expand System Preferences, I see (irrelevant columns omitted):
System Preferences | 22033 |
com.apple.preference.network.remoteservice | 22043 |
I.e. Activity Monitor knows that remoteservice was created by System Preferences.
However, when I use 'ps' from the command line, both processes' parent PID values are 1 (launchd):
$ ps -ww -o 'pid,ppid,command' -p 22033,22043
22033 | 1 | /Applications/System Preferences.app/Contents/MacOS/System Preferences |
22043 | 1 | /System/Library/PreferencePanes/Network.prefPane/Contents/XPCServices/com.apple.preference.network.remoteservice.xpc/Contents/MacOS/com.apple.preference.network.remoteservice |
sysctl("kern.proc.pid") is the same.
How can I learn that remoteservice (pid 22043) was created by System Preferences (pid 22033)?
This is OS X Yosemite 10.10.5, but I believe El Capitan behaves the same way.