First of all, the process name does not uniquely identify the process. There could be many processes with the same name, or processes may even change their name as you see them (ie, the PostgreSQL Server expands and changes argv [0] so you can see who is the master, who is the worker process, etc.). But in any case, you will need an API to list the processes and get their details - procps will do this for you.
UPDATE: Oh, I did not notice OSX for the first time. For OS X, you should use the NetBSD API (don't ask). See the KVM (kernel data library) documentation . The API is different, the idea is the same.
user405725
source share