[Spice-devel] [PATCH spice-xpi 1/2] xpi: use safer g_environ_setenv()

Christophe Fergeau cfergeau at redhat.com
Tue Jan 29 01:58:09 PST 2013


Hey,

On Mon, Jan 28, 2013 at 07:03:56PM +0100, Marc-André Lureau wrote:
> Quoting GLib:
> 
> Environment variable handling in UNIX is not thread-safe, and your
> program may crash if one thread calls g_setenv() while another thread
> is calling getenv(). (And note that many functions, such as gettext(),
> call getenv() internally.) This function is only safe to use at the
> very start of your program, before creating any other threads (or
> creating objects that create worker threads of their own).
> 
> If you need to set up the environment for a child process, you can use
> g_get_environ() to get an environment array, modify that with
> g_environ_setenv() and g_environ_unsetenv(), and then pass that array
> directly to execvpe(), g_spawn_async(), or the like.

Did you observe actual issues with that in spice-xpi, or is it just
theoritical? While the patches looks good, g_environ_setenv was added in
glib 2.32, which may be too recent.

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20130129/6031bbec/attachment.pgp>


More information about the Spice-devel mailing list