If I load a dll/so file at runtime (i.e. using LoadLibrary()
or dlopen()
), what is the behavior of the C++ atexit()
function? Does it get called if I unload the library before the application exits? And can I expect the same behavior on all platforms? (Specifically, windows and unix-like systems)
Under windows: when you call FreeLibrary then for each dll there will be executed atexit
functions chain. It is important to note that dll's gets unloaded in unspecified order so do not add atexit
handlers that depends on some other dll's globals.
Here is some more info link: http://msdn.microsoft.com/en-us/library/988ye33t.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With