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)
If I load a dll/so file at runtime (i.e. using LoadLibrary() or dlopen() ),
Share
Under windows: when you call FreeLibrary then for each dll there will be executed
atexitfunctions chain. It is important to note that dll’s gets unloaded in unspecified order so do not addatexithandlers that depends on some other dll’s globals.Here is some more info link: http://msdn.microsoft.com/en-us/library/988ye33t.aspx