'What happens to a dlopen-ed library if my process crashes?
According to the documentation, dlclose
decrements a reference counter. But what happens if my process crashes, or if I don't call dlclose
it before it finishes? Will the reference counter still get decremented, and if so, how?
Solution 1:[1]
According to the documentation, dlclose decrements a reference counter.
This reference counter is inside the dynamic loader and only has meaning in a particular process. It has no meaning for the OS (which doesn't care).
But what happens if my process crashes, or if I don't call dlclose it before it finishes?
Your process "evaporates into thin air". Any reference counts local to that process evaporate with it.
Will the reference counter still get decremented, and if so, how?
That reference count will simply ceases to exist.
However, the OS keeps its own reference counts on any open files and mmap
mappings established by the process (only indirectly related to dlopen()
), and the OS will decrement these counts. If, as a result, any such reference count drops to 0, the corresponding mapping will be removed (by the OS).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |