From 51166d0127d6d77ae7e4782887a76462858fdd91 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Mon, 26 Sep 2011 14:17:43 -0400 Subject: [PATCH] Add thread-safety warnings to the g_setenv() and g_unsetenv() docs https://bugzilla.gnome.org/show_bug.cgi?id=659326 --- glib/gutils.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/glib/gutils.c b/glib/gutils.c index c7f2763b1..12ad096e0 100644 --- a/glib/gutils.c +++ b/glib/gutils.c @@ -1331,6 +1331,16 @@ _g_getenv_nomalloc (const gchar *variable, * Note that on some systems, when variables are overwritten, the memory * used for the previous variables and its value isn't reclaimed. * + * + * 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). + * + * * Returns: %FALSE if the environment variable couldn't be set. * * Since: 2.4 @@ -1430,8 +1440,16 @@ extern char **environ; * * Note that on some systems, when variables are overwritten, the memory * used for the previous variables and its value isn't reclaimed. - * Furthermore, this function can't be guaranteed to operate in a - * threadsafe way. + * + * + * Environment variable handling in UNIX is not thread-safe, and your + * program may crash if one thread calls g_unsetenv() 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). + * * * Since: 2.4 **/