]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
[PATCH cgmanager chown: don't do a gratuitous fork
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Wed, 29 Jan 2014 16:17:09 +0000 (16:17 +0000)
committerStéphane Graber <stgraber@ubuntu.com>
Wed, 29 Jan 2014 16:22:23 +0000 (16:22 +0000)
userns_exec_1() clones a new task to manipulate.  We don't
need to fork before calling that.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
src/lxc/cgmanager.c

index 0fb57cf64f710be1d798e589bcd3a052d6c7dc13..76e628d8552f8cff0539962ac34aec66591dbfcd 100644 (file)
@@ -246,7 +246,6 @@ static int chown_cgroup_wrapper(void *data)
 static bool chown_cgroup(const char *controller, const char *cgroup_path,
                        struct lxc_conf *conf)
 {
-       pid_t pid;
        struct chown_data data;
        data.controller = controller;
        data.cgroup_path = cgroup_path;
@@ -257,20 +256,11 @@ static bool chown_cgroup(const char *controller, const char *cgroup_path,
                return true;
        }
 
-       if ((pid = fork()) < 0) {
-               SYSERROR("fork");
+       if (userns_exec_1(conf, chown_cgroup_wrapper, &data) < 0) {
+               ERROR("Error requesting cgroup chown in new namespace");
                return false;
        }
-       if (pid > 0) {
-               if (wait_for_pid(pid)) {
-                       ERROR("Error chowning cgroup");
-                       return false;
-               }
-               return true;
-       }
-       if (userns_exec_1(conf, chown_cgroup_wrapper, &data) < 0)
-               exit(1);
-       exit(0);
+       return true;
 }
 
 struct cgm_data {