From d17c299e5742dfa34765b1f558e34d238ee83469 Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Sat, 11 Jan 2020 13:07:03 +1100 Subject: [PATCH] core-util: Set nice value for the task group --- src/pulsecore/core-util.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c index 601b1d1df..f9898a625 100644 --- a/src/pulsecore/core-util.c +++ b/src/pulsecore/core-util.c @@ -684,6 +684,10 @@ char *pa_strlcpy(char *b, const char *s, size_t l) { #ifdef HAVE_SYS_RESOURCE_H static int set_nice(int nice_level) { +#ifdef __linux__ + FILE* f; +#endif + #ifdef HAVE_DBUS DBusError error; DBusConnection *bus; @@ -692,6 +696,15 @@ static int set_nice(int nice_level) { dbus_error_init(&error); #endif +#ifdef __linux__ + if (!(f = pa_fopen_cloexec("/proc/self/autogroup", "w"))) { + pa_log_info("Failed to open autogroup"); + } else { + fprintf(f, "%d", nice_level); + fclose(f); + } +#endif + #ifdef HAVE_SYS_RESOURCE_H if (setpriority(PRIO_PROCESS, 0, nice_level) >= 0) { pa_log_debug("setpriority() worked.");