chiark / gitweb /
main: set PR_SET_CHILD_REAPER for MANAGER_USER
authorAuke Kok <auke-jan.h.kok@intel.com>
Tue, 24 Jul 2012 22:13:11 +0000 (00:13 +0200)
committerKay Sievers <kay@vrfy.org>
Tue, 24 Jul 2012 22:17:30 +0000 (00:17 +0200)
Become the reaper for all children part of the user session. Tested
with several forking services.

src/core/main.c
src/shared/missing.h

index c7a7a87e7a6a525a336678b965980aa9ffc241e2..1326b94f689814ad6edeaec253cb29d74804cbc5 100644 (file)
@@ -1500,6 +1500,15 @@ int main(int argc, char *argv[]) {
                 }
         }
 
+        if (arg_running_as == MANAGER_USER) {
+                /* Become reaper of our children */
+                r = prctl(PR_SET_CHILD_SUBREAPER, 1);
+                if (r < 0)
+                        log_error("Failed to prctl(PR_SET_CHILD_SUBREAPER): %s", strerror(-r));
+                if (r == -EINVAL)
+                        log_error("Perhaps the kernel version is too old (< 3.4?)");
+        }
+
         r = manager_new(arg_running_as, &m);
         if (r < 0) {
                 log_error("Failed to allocate manager object: %s", strerror(-r));
index e600acc0b18e5d0cf04cdb25cb36a6fa2e2e9e8e..df3fd0e839d59ef47882041e638bce112f7809f1 100644 (file)
@@ -190,3 +190,7 @@ static inline pid_t gettid(void) {
 #ifndef PR_SET_NO_NEW_PRIVS
 #define PR_SET_NO_NEW_PRIVS 38
 #endif
+
+#ifndef PR_SET_CHILD_SUBREAPER
+#define PR_SET_CHILD_SUBREAPER 36
+#endif