The C standard library function atexit is broken everywhere
The ELF specification prescribes for use as the shared library destructor mechanism:
Since there is no mention of unloading a shared library in the document, I think it’s safe to assume, that unloading was not a concern at the time of writing. You can not use anymore for shared library destructors, since these do not happen at “base process termination”, but at any time gets invoked. But Linux calls all functions of a shared library at the time of … And it seems most other OS as well.
Source: www.mulle-kybernetik.com