summaryrefslogtreecommitdiff
path: root/glib/gutils.h
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2011-10-15 15:52:28 -0400
committerMatthias Clasen <mclasen@redhat.com>2011-10-15 15:54:45 -0400
commit409d93148f2d95c2966f75fe0901edd1e06c99a9 (patch)
tree2d96297c3bb9d21f0da809870b28883ca5b0abaa /glib/gutils.h
parent5ff803d91f252bfeb4a9cfaf2f94ecdea6e6a687 (diff)
downloadglib-409d93148f2d95c2966f75fe0901edd1e06c99a9.tar.gz
gutils: Add functions for working with environment arrays
When spawning a child process, it is not safe to call setenv() before the fork() (because setenv() isn't thread-safe), but it's also not safe to call it after the fork() (because it's not async-signal-safe). So the only safe way to alter the environment for a child process from a threaded program is to pass a fully-formed envp array to exec*/g_spawn*/etc. So, add g_environ_getenv(), g_environ_setenv(), and g_environ_unsetenv(), which act like their namesakes, but work on arbitrary arrays rather than working directly on the environment. http://bugzilla.gnome.org/show_bug.cgi?id=659326
Diffstat (limited to 'glib/gutils.h')
-rw-r--r--glib/gutils.h27
1 files changed, 18 insertions, 9 deletions
diff --git a/glib/gutils.h b/glib/gutils.h
index f43993407..47d4b16ff 100644
--- a/glib/gutils.h
+++ b/glib/gutils.h
@@ -265,17 +265,26 @@ void g_nullify_pointer (gpointer *nullify_location);
#endif
#endif
-const gchar * g_getenv (const gchar *variable);
-gboolean g_setenv (const gchar *variable,
- const gchar *value,
- gboolean overwrite);
-void g_unsetenv (const gchar *variable);
-gchar** g_listenv (void);
-gchar** g_get_environ (void);
+const gchar * g_getenv (const gchar *variable);
+gboolean g_setenv (const gchar *variable,
+ const gchar *value,
+ gboolean overwrite);
+void g_unsetenv (const gchar *variable);
+gchar ** g_listenv (void);
+
+gchar ** g_get_environ (void);
+const gchar * g_environ_getenv (gchar **envp,
+ const gchar *variable);
+gchar ** g_environ_setenv (gchar **envp,
+ const gchar *variable,
+ const gchar *value,
+ gboolean overwrite) G_GNUC_WARN_UNUSED_RESULT;
+gchar ** g_environ_unsetenv (gchar **envp,
+ const gchar *variable) G_GNUC_WARN_UNUSED_RESULT;
/* private */
-const gchar* _g_getenv_nomalloc (const gchar *variable,
- gchar buffer[1024]);
+const gchar* _g_getenv_nomalloc (const gchar *variable,
+ gchar buffer[1024]);
/**
* GVoidFunc: