瀏覽代碼

ResourceGraph.MenuApplet: Disown child processes after spawning

Andreas Kling 5 年之前
父節點
當前提交
8cf818e7c7
共有 1 個文件被更改,包括 6 次插入1 次删除
  1. 6 1
      MenuApplets/ResourceGraph/main.cpp

+ 6 - 1
MenuApplets/ResourceGraph/main.cpp

@@ -35,6 +35,7 @@
 #include <LibGUI/Painter.h>
 #include <LibGUI/Painter.h>
 #include <LibGUI/Window.h>
 #include <LibGUI/Window.h>
 #include <LibGfx/Palette.h>
 #include <LibGfx/Palette.h>
+#include <serenity.h>
 #include <spawn.h>
 #include <spawn.h>
 #include <stdio.h>
 #include <stdio.h>
 
 
@@ -109,8 +110,12 @@ private:
             return;
             return;
         pid_t child_pid;
         pid_t child_pid;
         const char* argv[] = { "SystemMonitor", nullptr };
         const char* argv[] = { "SystemMonitor", nullptr };
-        if ((errno = posix_spawn(&child_pid, "/bin/SystemMonitor", nullptr, nullptr, const_cast<char**>(argv), environ)))
+        if ((errno = posix_spawn(&child_pid, "/bin/SystemMonitor", nullptr, nullptr, const_cast<char**>(argv), environ))) {
             perror("posix_spawn");
             perror("posix_spawn");
+        } else {
+            if (disown(child_pid) < 0)
+                perror("disown");
+        }
     }
     }
 
 
     static void get_cpu_usage(unsigned& busy, unsigned& idle)
     static void get_cpu_usage(unsigned& busy, unsigned& idle)