Upstgream-Bug: http://bugs.freedesktop.org/show_bug.cgi?id=8934 Created-by: Kimmo Hämäläinen Updated-by: Guillem Jover Index: dbus-1.2.4/dbus/dbus-spawn.c =================================================================== --- dbus-1.2.4.orig/dbus/dbus-spawn.c +++ dbus-1.2.4/dbus/dbus-spawn.c @@ -35,6 +35,9 @@ #ifdef HAVE_ERRNO_H #include #endif +#ifdef _POSIX_PRIORITY_SCHEDULING +#include +#endif /** * @addtogroup DBusInternalsUtils @@ -1061,6 +1064,23 @@ babysit (pid_t grandchild_pid, exit (1); } +static void +setup_child_priority (void) +{ + int p; +#ifdef _POSIX_PRIORITY_SCHEDULING + struct sched_param sched_param; + + sched_param.sched_priority = 0; + sched_setscheduler (0, SCHED_OTHER, &sched_param); +#endif + + errno = 0; + p = getpriority (PRIO_PROCESS, 0); + if (!errno && p < 0) + setpriority (PRIO_PROCESS, 0, 0); +} + /** * Spawns a new process. The executable name and argv[0] * are the same, both are provided in argv[0]. The child_setup @@ -1198,6 +1218,13 @@ _dbus_spawn_async_with_babysitter (DBusB } else if (grandchild_pid == 0) { + /* put the child into a new session and process group, so that + * killpg() can be used safely */ + if (setsid () == -1) + _dbus_warn ("setsid() failed: %s\n", _dbus_strerror (errno)); + + setup_child_priority (); + do_exec (child_err_report_pipe[WRITE_END], argv, env,