On Sat, 20 Dec 2025 16:44:29 +0100
Martin Husemann <[email protected]> wrote:

> On Sat, Dec 20, 2025 at 03:40:03PM +0000, Sad Clouds wrote:
> > I haven't looked at the implementation but I imagine on Linux when
> > dlclose() is called, all of the atexit() handlers are scanned and
> > checked to see if they point to the address space of the shared object
> > that is being closed. If any of them match, they are executed and then
> > removed from the list, so they are not called again on exit().
> 
> Yeah, some hack like that, but I guess only removing them from the list.
> It is unclear if calling the function on dlclose() would do the right
> thing (and it would be a violation of the standard).
> 
> Martin

Linux atexit(3) man page:

"Since  glibc  2.2.3, atexit() (and on_exit(3)) can be used within a
shared library to establish functions that are called when the shared
library is unloaded."

So looks like these are called on dlclose().

Reply via email to