__cxa_finalize and `on_exit'

Mark Mitchell mark at codesourcery.com
Sat Dec 18 02:06:38 UTC 1999


>>>>> "Jim" == Jim Dehnert <dehnert at baalbek.engr.sgi.com> writes:

    Jim> OK, I understand now.  This could work, _except_ that it
    Jim> would fail to put the on_exit calls into "proper" sequence
    Jim> without further modification.  This isn't a Standard issue,

Why?

    Jim> of course, since on_exit is a non-standard extension, but my
    Jim> guess is that users think of it as equivalent to atexit (with
    Jim> enhancements).  So wouldn't it be cleaner to finish the job?

I believe I did; I just implemented this in GNU libc.  All of atexit,
on_exit, and __cxa_atexit share the same list of exit functions.  When
__cxa_finalize is called from a DSO, only __cxa_atexit functions are
called.  When exit is called (on exit from the main executable), all
of the functions are called, in reverse order of registration.  The
main executable therefore does not call __cxa_finalize at all.  Works
like a charm, as far as I can tell.

--
Mark Mitchell                   mark at codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com




More information about the cxx-abi-dev mailing list