graydon/rust — Issue #1333: fix setenv and getenv (especially on os x)
Author: boggle
Created: 2011-12-19 15:24:27+00:00
State: open

I digged a bit into getenv not working on os x and found two issues:

* Sadly the man page says:

Successive calls to setenv() or putenv() assigning a differently sized
value to the same name will result in a memory leak. The FreeBSD seman-
tics for these functions (namely, that the contents of value are copied
and that old values remain accessible indefinitely) make this bug
unavoidable. Future versions may eliminate one or both of these semantic
guarantees in order to fix the bug.

maybe this can be fixed by an additional unsetenv calls.

* setenv/getenv are not safe for concurrent use and thus should be wrapped by a task that
processes set/get commands and is started on demand /or/ protected by a lock in the runtime.
opinions on the correct approach wanted.