B
Ben Bacarisse
Laurent Deniau said:On 15 nov, 23:43, Ben Bacarisse <[email protected]> wrote:
I am not talking to promote this style, but there is cases where this
is required like in "stack unwinding a-la-C++". You have a global
pointer pointing to a linked list of "stacked" pointers to automatic
variables holding critical resources and a proper implementation
should call their destructor before exit()ing. I am open to any
alternative, but the problem is not obvious.
My comment was just a general "avoid this" remark to other readers. I
assumed from your previous posts that you were probably looking into
some automatic C++-style cleanup implementation.
I can offer two ideas (you've probably thought of both!):
(1) Build you own "parallel" stack. Your objects get put here rather
than in automatic storage.
(2) Take over the implementation of exit (yes, not really permitted
but probably safe enough). Of course if you can insist that programs
use your version you don't need to take anything over. Your clean_exit
function can do the cleanup required before calling exit.