3 ms·
There's two distinct concepts that are conflated for statically linked executables. On process death vs on module death. Is the function to clean up the proces
by barrkel 7y ago
There's two distinct concepts that are conflated for statically linked executables.
On process death vs on module death. Is the function to clean up the process, or is it to clean up the module?
I think the argument for module cleanup is stronger, irrespective of the difficulty of registering code that's supposed to last longer than the calling address space. The module had nothing before it was loaded, it should leave nothing behind when it is unloaded. It's symmetrical.
The difficulty of providing an executable callback that outlives its module just seals the deal.
- zwetan 7y agoit should definitively clean up the module you could make the same argument with threads main process vs child threads, you would expect atexit installed in the child thread to execute before the main process atexit installed functions
- barrkel 7y agoIf it were thread local, sure, but they'd need access to a module cleanup function too, as there's no necessary tie between thread lifetime and module lifetime.