summaryrefslogtreecommitdiffstats
path: root/src/pulsecore/core-util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pulsecore/core-util.c')
-rw-r--r--src/pulsecore/core-util.c54
1 files changed, 48 insertions, 6 deletions
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index 1c8c6780..1daa46eb 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -116,6 +116,7 @@
#include <pulsecore/thread.h>
#include <pulsecore/strbuf.h>
#include <pulsecore/usergroup.h>
+#include <pulsecore/strlist.h>
#include "core-util.h"
@@ -124,6 +125,8 @@
#define MSG_NOSIGNAL 0
#endif
+static pa_strlist *recorded_env = NULL;
+
#ifdef OS_IS_WIN32
#define PULSE_ROOTENV "PULSE_ROOT"
@@ -609,6 +612,11 @@ static int set_scheduler(int rtprio) {
return -1;
}
+ /* We need to disable exit on disconnect because otherwise
+ * dbus_shutdown will kill us. See
+ * https://bugs.freedesktop.org/show_bug.cgi?id=16924 */
+ dbus_connection_set_exit_on_disconnect(bus, FALSE);
+
r = rtkit_make_realtime(bus, 0, rtprio);
dbus_connection_unref(bus);
@@ -677,6 +685,11 @@ static int set_nice(int nice_level) {
return -1;
}
+ /* We need to disable exit on disconnect because otherwise
+ * dbus_shutdown will kill us. See
+ * https://bugs.freedesktop.org/show_bug.cgi?id=16924 */
+ dbus_connection_set_exit_on_disconnect(bus, FALSE);
+
r = rtkit_make_high_priority(bus, 0, nice_level);
dbus_connection_unref(bus);
@@ -1877,17 +1890,17 @@ char *pa_make_path_absolute(const char *p) {
static char *get_path(const char *fn, pa_bool_t prependmid, pa_bool_t rt) {
char *rtp;
- if (pa_is_path_absolute(fn))
- return pa_xstrdup(fn);
-
rtp = rt ? pa_get_runtime_dir() : pa_get_state_dir();
- if (!rtp)
- return NULL;
-
if (fn) {
char *r;
+ if (pa_is_path_absolute(fn))
+ return pa_xstrdup(fn);
+
+ if (!rtp)
+ return NULL;
+
if (prependmid) {
char *mid;
@@ -2451,9 +2464,38 @@ void pa_set_env(const char *key, const char *value) {
pa_assert(key);
pa_assert(value);
+ /* This is not thread-safe */
+
putenv(pa_sprintf_malloc("%s=%s", key, value));
}
+void pa_set_env_and_record(const char *key, const char *value) {
+ pa_assert(key);
+ pa_assert(value);
+
+ /* This is not thread-safe */
+
+ pa_set_env(key, value);
+ recorded_env = pa_strlist_prepend(recorded_env, key);
+}
+
+void pa_unset_env_recorded(void) {
+
+ /* This is not thread-safe */
+
+ for (;;) {
+ char *s;
+
+ recorded_env = pa_strlist_pop(recorded_env, &s);
+
+ if (!s)
+ break;
+
+ unsetenv(s);
+ pa_xfree(s);
+ }
+}
+
pa_bool_t pa_in_system_mode(void) {
const char *e;