Hi all !
First, thank you for your great work on this library.
I just use it for the first time. I write the following code to test unix
fork:
===============================================
(asdf:oos 'asdf:load-op :cffi)
(defpackage :testfork
(:use :common-lisp :cffi))
(in-package :testfork)
(defcvar "errno" :int)
(cffi:defcfun ("getpid" unix-getpid) :int)
(cffi:defcfun ("getuid" unix-getuid) :int)
(cffi:defcfun ("getgid" unix-getgid) :int)
(cffi:defcfun ("fork" unix-fork) :int)
(cffi:defcfun ("exit" unix-exit) :void (code :int))
(cffi:defcfun ("wait" unix-wait) :int (statloc :pointer))
(when (zerop (unix-fork))
(with-foreign-pointer-as-string (str 6 str-size :encoding :ascii)
(lisp-string-to-foreign "Hello, foreign world!" str str-size))
(unix-exit 0))
(progn
(format t "I'm parent, Pid=~A~%" (unix-getpid))
(format t "one child claimed!~A~%" (unix-wait (cffi:null-pointer)))
)
===============================================
When I add two lines using with-foreign-pointer-as-string and
lisp-string-to-foreign, my SBCL always crashes, and tell me
" fatal error encountered in SBCL pid XXXX:
Unhandled memory fault. "
I have tried other memory allocation macros, I get the same result. But if
I remove them, the program runs and exits normally.
What's the problem about allocating memory in child process? Or I use them
in the wrong way?
My environment is : OSX 10.8.3 Processor Intel Core i7, SBCL
1.0.55.0-abb03f9, cffi_0.10.7.1 installed from quicklisp
Thank you very much!