[plt-scheme] reliable exit handlers for foreign functions

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue Dec 9 18:52:46 EST 2008

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().

Matthew



Posted on the users mailing list.