Which all processes use a shared library

I have a shared library (.so file) on UNIX. I need to know what all running processes are using. Does unix provide such a utility / command?

+3
source share
3 answers

You can check the contents /proc/<pid>/mapsto see which files are displayed in each process. You will have to check each process, but it is easier than it seems:

$ grep -l /lib/libnss_files-2.11.1.so /proc/*/maps
/proc/15620/maps
/proc/22439/maps
/proc/22682/maps
/proc/32057/maps

This only works with the Linux file system /proc, AFAIK.

+5
source

The quick fix was to use the lsof command

[root@host]# lsof /lib/libattr.so.1
COMMAND     PID USER  FD   TYPE DEVICE  SIZE   NODE NAME
gdm-binar 11442 root mem    REG    8,6 30899 295010 /lib/libattr.so.1.1.0
gdm-binar 12195 root mem    REG    8,6 30899 295010 /lib/libattr.so.1.1.0

This should work not only for files .so, but also for any other files, dirs, mount points, etc.

N.B. lsof , , , , *.so, . , .

+3

Make in all the directories that interest us

ldd * >ldd_output
vi ldd_output

Then find the name of the library, for example. "ALib.so". This shows all modules related to, for example, "ALib.so"

0
source

Source: https://habr.com/ru/post/1779995/


All Articles