This question already has an answer here:

I know that ldd utility can list all libraries linked to a process but I want it the other way around. I want all processes linked to a library. I want to replace a shared library without crashing the system and make sure that the process reads the new library. A safe way is to check how many processes are using it and then shut them down using a script, replace the library and start them again. I'll be really glad if there is a better way to do it. thanks in advance.

marked as duplicate by Gilles linux Mar 3 '15 at 0:14

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Do you really mean processes (i.e. running programs) or do you mean program binaries? For the former you can use lsof, the latter requires ldd-ing all programs binaries you're interested in (typically /bin/*, /sbin/*, /usr/sbin/* and so on) and grepping for the shared lib you're interested in. – countermode Mar 2 '15 at 22:57
  • i mean running processes. – Kanwar Saad Mar 2 '15 at 23:01
  • If a process is linked to a shared library, and you delete the library, then the process will be fine. Though no disk blocks will be freed until all processes stop using the library (this is true of all files on Unix systems). The only problem could be if there are version dependencies i.e. lib-a version1 depends on lib-b version1, and lib-a version2 depends on lib-b version2. In that case there could be a race problem on process load. – ctrl-alt-delor Mar 2 '15 at 23:09
  • 1
  • the API of the library is not changed so I can safely replace the lib. But I cant figure out a proper way to replace the binary. The processes using the library crashes when I replace the current binary. – Kanwar Saad Mar 2 '15 at 23:14

Typically, for finding the processes sharing the library, you can use the command lsof shared_library_path. It will list out all the processes. Source : Here
A Similar question was asked before here.

Not the answer you're looking for? Browse other questions tagged or ask your own question.