Getting a list of used libraries by a running process (unix)

后端 未结 7 477
梦如初夏
梦如初夏 2020-12-23 20:30

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

7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-23 21:06

    if lsof is not installed, you can simply cat /proc/$pid/maps

    you can also check on disk executables with ldd to see what libs they will open (but that doesn't show libraries opened dynamically using dlopen()).

    As for monitoring new processes, you can possibly add an inotify watch on /proc to monitor the creation/destruction of new numeric only directories.

    Update: inotify on /proc doesn't work, but there are apparently alternatives, see this thread

提交回复
热议问题