The Sample Process feature in Activity Monitor is quite a useful thing. However, I need to do the same thing (take samples) of a certain process from another running process (C/C++) or a command line.
Is there any way to do this? I have been googling for this since a few days without any luck.
There is a command-line utility sample
.
Example:
sample Safari -file /dev/stdout
It will get exactly the same output with Activity Monitor.