[vte] systemd: Put child process into the parent's slice



commit 1ea1c0495dc5b51f5228eecd84d1c3e3aca98613
Author: Christian Persch <chpe src gnome org>
Date:   Tue Feb 4 18:13:47 2020 +0100

    systemd: Put child process into the parent's slice

 src/systemd.cc | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
---
diff --git a/src/systemd.cc b/src/systemd.cc
index eeefd2f8..7610b49f 100644
--- a/src/systemd.cc
+++ b/src/systemd.cc
@@ -34,9 +34,11 @@ create_scope_for_pid_sync(pid_t pid,
                           GCancellable* cancellable,
                           GError** error)
 {
+        auto const parent_pid = getpid();
+
         {
                 char* unit = nullptr;
-                if (auto r = sd_pid_get_user_unit(pid, &unit) < 0) {
+                if (auto r = sd_pid_get_user_unit(parent_pid, &unit) < 0) {
                         g_set_error(error, G_IO_ERROR, g_io_error_from_errno(-r),
                                     "Failed sd_pid_get_user_unit(%d): %s",
                                     pid,
@@ -76,6 +78,15 @@ create_scope_for_pid_sync(pid_t pid,
         g_variant_builder_close(builder); // v
         g_variant_builder_close(builder); // (sv)
 
+        char* slice = nullptr;
+        if (sd_pid_get_user_slice(parent_pid, &slice) >= 0) {
+                g_variant_builder_add(builder, "(sv)", "Slice", g_variant_new_string(slice));
+                free(slice);
+        } else {
+                // Fallback
+                g_variant_builder_add(builder, "(sv)", "Slice", 
g_variant_new_string("apps-org.gnome.vte.slice"));
+        }
+
         g_variant_builder_close(builder); // a(sv)
 
         // No auxiliary units


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]