What is the behavior of atexit () in dll / so loaded at runtime?

If I load the dll / so file at runtime (i.e. using LoadLibrary() or dlopen() ), what is the behavior of the C ++ atexit() function? Is this called if I unload the library before the application exits? And can you expect the same behavior on all platforms? (In particular, windows and unix-like systems)

+4
source share
1 answer

In windows: when you call FreeLibrary, then for each dll a chain of atexit functions will be executed. It is important to note that the dll is unloaded in the unspecified order, so do not add atexit handlers that depend on some other global dll globals.

Here is more information: http://msdn.microsoft.com/en-us/library/988ye33t.aspx

+4
source

Source: https://habr.com/ru/post/1388846/


All Articles