On Fri, Jun 12, 2015 at 6:52 AM, Stelian Ionescu <sionescu@cddr.org> wrote:
You can have both, which IMO is the right thing wrt. to backwards-compatibility with C programs.
Interesting. But, how exactly would this work? The C library provides no signal to invalidate a cache when its copy of the environment changes As such, it seems impossible to efficiently keep a copy of the environment in Lisp consistent. Without consistency, I am not sure how backward compatibility is maintained.
There is no "its copy", just a single array that putenv() changes destructively. During an exec(), the runtime linker allocates that array, having a fixed maximum size baked in the kernel, at a fixed offset in the process address space. If something modifies that in-place and screws it up, there's no backup.
With IOlib one can query the process-level environment or turn that into an object, manipulate it and pass it to CREATE-PROCESS. See https://github.com/sionescu/iolib/blob/master/src/os/os-unix.lisp#L10.
Thanks for the pointer. I noticed that your hash-table construction does not check for the preexistence of a value when doing inserts from the environment list (on line 101). While uncommon, this nevertheless is a discrepancy between the behavior of getenv in your library and the and getenv in the C library. This can create a security issue.
Thanks for the notice. I opened https://github.com/sionescu/iolib/issues/24 -- Stelian Ionescu a.k.a. fe[nl]ix Quidquid latine dictum sit, altum videtur. http://common-lisp.net/project/iolib