[plt-scheme] reliable exit handlers for foreign functions

From: Dimitris Vyzovitis (vyzo at media.mit.edu)
Date: Tue Dec 9 19:32:40 EST 2008

On Tue, 9 Dec 2008, Eli Barzilay wrote:

> In any case, I couldn't find it either on my system -- the only
> place that had it is /usr/lib64/dietlibc/lib-x86_64/libc.so.

There is another insight here: atexits tend to be dangerous with dsos 
(ouch when the atexit handler has been unloaded because of a dlclose).
ELF provides _init/_fini sections, but of course such functionality is 
infeasible for ffi.

So, just trying find a proper solution:

Eli, is it possible to add a facility for exit/unload handlers associated 
with ffi-libs?

Something like
(register-unload-handler ffi-lib thunk)
to be called right before the dlclose (or when scheme exits, in the case 
there is no dlclose at all)

-- vyzo


Posted on the users mailing list.