summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTanu Kaskinen <tanu.kaskinen@linux.intel.com>2014-10-02 12:14:09 +0300
committerTanu Kaskinen <tanu.kaskinen@linux.intel.com>2014-10-02 12:14:09 +0300
commitf04e31dc5ebf252fc694632b6b85f5d2a5175389 (patch)
treec0b6bb9bd72ca4903230a7b68499aa92ce30290e
parent0e44b127d0a1fb70803a9bd7b12f8dfcdb80cf58 (diff)
core-util: Add pa_unset_env()
Since we already have pa_set_env(), it's nice to also have a corresponding function for unsetting environment variables.
-rw-r--r--src/pulsecore/core-util.c18
-rw-r--r--src/pulsecore/core-util.h1
-rw-r--r--src/pulsecore/start-child.c2
3 files changed, 15 insertions, 6 deletions
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index 6b7cd3555..e9843ef78 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -2859,6 +2859,18 @@ void pa_set_env(const char *key, const char *value) {
#endif
}
+void pa_unset_env(const char *key) {
+ pa_assert(key);
+
+ /* This is not thread-safe */
+
+#ifdef OS_IS_WIN32
+ SetEnvironmentVariable(key, NULL);
+#else
+ unsetenv(key);
+#endif
+}
+
void pa_set_env_and_record(const char *key, const char *value) {
pa_assert(key);
pa_assert(value);
@@ -2881,11 +2893,7 @@ void pa_unset_env_recorded(void) {
if (!s)
break;
-#ifdef OS_IS_WIN32
- SetEnvironmentVariable(s, NULL);
-#else
- unsetenv(s);
-#endif
+ pa_unset_env(s);
pa_xfree(s);
}
}
diff --git a/src/pulsecore/core-util.h b/src/pulsecore/core-util.h
index d7172999e..8db56c5ea 100644
--- a/src/pulsecore/core-util.h
+++ b/src/pulsecore/core-util.h
@@ -210,6 +210,7 @@ int pa_reset_sigs(int except, ...);
int pa_reset_sigsv(const int except[]);
void pa_set_env(const char *key, const char *value);
+void pa_unset_env(const char *key);
void pa_set_env_and_record(const char *key, const char *value);
void pa_unset_env_recorded(void);
diff --git a/src/pulsecore/start-child.c b/src/pulsecore/start-child.c
index 7f55d4e29..8318b9bcb 100644
--- a/src/pulsecore/start-child.c
+++ b/src/pulsecore/start-child.c
@@ -92,7 +92,7 @@ int pa_start_child_for_read(const char *name, const char *argv1, pid_t *pid) {
/* Make sure our children are not influenced by the
* LD_BIND_NOW we set for ourselves. */
- unsetenv("LD_BIND_NOW");
+ pa_unset_env("LD_BIND_NOW");
#ifdef PR_SET_PDEATHSIG
/* On Linux we can use PR_SET_PDEATHSIG to have the helper