vga_init and atexit

Search this archive.

From: Peter Wang (tjaden@alphalink.com.au)
Date: Fri 30 Nov 2001 - 02:19:48 IST


Hello,

I'm writing on behalf of the Allegro developers.  (Allegro is a game
programming library.)

In Allegro we use svgalib from a dynamically linked module.  The
problem is that `vga_init' hooks `__vga_atexit' with `atexit', so if
we unload the module before the program terminates, the `atexit'
mechanism ends up pointing to invalid memory, and a segfault occurs
when the program ends.

We would like a way to initialise svgalib without it hooking
`__vga_atexit', and also have access to `__vga_atexit' ourselves, so
we can shut down svgalib before unloading the module.


The simplest way I can think of is probably to provide another init
function which takes a pointer to atexit.  Then there are two options:

(1) If the pointer is NULL, don't hook `__vga_atexit'.  Then you'd
    need to expose the shutdown routine.  This is what we do in
    Allegro.

(2) If you don't want to expose the shutdown routine, we could pass a
    dummy atexit function to the new init routine to trap the address
    of `__vga_atexit'.


What do you think?


[Please Cc: me as I'm not subscribed to this list.  Thanks.]

------------------------------------------------------------------
Unsubscribe:  To:   listbot@svgalib.org
              Body: unsubscribe linux-svgalib


This archive was generated by hypermail 2.1.4 : Wed 21 Jan 2004 - 22:10:24 IST