[plt-scheme] reliable exit handlers for foreign functions
At Tue, 9 Dec 2008 16:52:46 -0700, Matthew Flatt wrote:
> At Tue, 9 Dec 2008 18:44:03 -0500 (EST), Dimitris Vyzovitis wrote:
> > Is there any reliable way to register atexit callbacks with ffi?
> >
> > I am trying to register a native thunk with atexit, but I am not getting
> > anywhere:
> > > (get-ffi-obj "atexit" #f _pointer)
> > ffi-obj: couldn't get "atexit" from #f (/usr/local/plt/bin/mzscheme:
> > undefined symbol: atexit)
> >
> > Trying libc doesn't go very far either:
> > > (get-ffi-obj "atexit" "libc" _pointer)
> > ffi-lib: couldn't open "libc.so" (/usr/lib64/libc.so: invalid ELF header)
> > ;; huh?
> > > (get-ffi-obj "atexit" "/lib/libc.so.6" _pointer)
> > ffi-obj: couldn't get "atexit" from "/lib/libc.so.6" (/lib/libc.so.6:
> > undefined symbol: atexit)
>
> I'm not sure why atexit() is unavailable, but try
> scheme_add_atexit_closer().
Sorry --- that's called once per object registered with the custodian.
It may work, but it's not really what you were looking for.
Matthew