mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-10-22 05:11:06 +02:00
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
This commit is contained in:
committed by
Matthias Clasen
parent
5ff803d91f
commit
409d93148f
@@ -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:
|
||||
|
Reference in New Issue
Block a user