[plt-scheme] reliable exit handlers for foreign functions

From: Eli Barzilay (eli at barzilay.org)
Date: Tue Dec 9 19:01:48 EST 2008

On Dec  9, 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,

I'm not sure either, but these "invalid ELF header" files are usually
some text file that describes how to actually look for the real .so
file.  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.  But I
did get on_exit() in the usual way, except that the man page says that
atexit() should be used instead...

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!


Posted on the users mailing list.