Reputation: 207
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?
Upvotes: 0
Views: 72
Reputation: 213754
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).
Upvotes: 2