How process hierarchy works in macOS I'm wondering how Activity Monitor relates these two process if the child (Safari Web Content) doesn't have the ppid of the main one (Safari). pstree, which uses the ppid to organize the tree, shows no relation between them.



Here's another example, caffeinate was launched from a shell script inside BetterTouchTool using nohup, and again pstree doesn't show any relation.



Actually what I need is to send a kill signal to "childs" like Safari Web Content using shell script or C api knowing only the "Safari" pid. And I think this might help.
The Safari "child" processes are actually children of the init system (launchd which has PID 1) which explains why pstree or other such unix tools cannot make use of the usual parent pid (or process group) relation:



% ps axo pid,ppid | egrep '81921|81925|82022'
81921     1
81925     1
82022     1


Instead you will need to use an Apple API; the launchctl utility indicates that the "domain" or "ASID" may be relevant:

% sudo launchctl procinfo 82022 | grep -1 81921

        domain = com.apple.xpc.launchd.domain.pid.Safari.81921
        asid = 100006
--
--

responsible pid = 81921
responsible unique pid = 81921
responsible path = /Applications/Safari.app/Contents/MacOS/Safari


But let's post this info before testing what something like launchctl kill ... does.

(Also note the above is from Mac OS X 10.11.6, the interfaces may have been changed by Apple since then.)