I need to find out what libraries a unix process has loaded and might use throughout it\'s lifetime. Is this possible and how. Or better yet, i have a library name and i nee
On Mac OS X you can use vmmap $pid
to get a list of mapped memory regions for a process. This does show all loaded libraries (at least it works for me here on 10.7.5).
ps -A
will give you a list of all processes, so ps -A | grep $APPNAME
will get you your process id $pid for use with vmmap $pid
. lsof -p $pid
also works.
The question seems to be asking for a dynamic method from C++. You could poll with these commands and analyse the results, although you may miss fast load/unload events.
lsof
is open source software under a BSD licence. Its source code no doubt provides some insight for how to do this from C/C++. See: http://en.wikipedia.org/wiki/Lsof