Reputation: 11
I've faced with the following problem in Linux. I have some application which uses external library (the application isn't linked with it). I open the library by dlopen
and use some symbols from it. The problem occurred when I try to unload library by dlclose
, I still see the library loaded in /proc/.../maps
.
More over an attempt to use following:
...
while(dlclose(module) == 0);
...
leads to infinite loop and the library is still loaded.
Is there any way to check/find who holds the library?
Upvotes: 1
Views: 2121
Reputation: 213385
From "man dlclose":
The function dlclose() decrements the reference count on the dynamic
library handle handle. If the reference count drops to zero and no
other loaded libraries use symbols in it, then the dynamic library
is unloaded.
You are most likely running afoul of the "no other loaded libraries use symbols" clause.
Your best bet is to run with LD_DEBUG=bindings
, and see which other libraries bind to the one you want to unload.
See also this question.
Upvotes: 3