[lxc-devel] [PATCH cgmanager chown: don't do a gratuitous fork
Serge Hallyn
serge.hallyn at ubuntu.com
Wed Jan 29 16:17:09 UTC 2014
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 at ubuntu.com>
---
src/lxc/cgmanager.c | 16 +++-------------
1 file changed, 3 insertions(+), 13 deletions(-)
diff --git a/src/lxc/cgmanager.c b/src/lxc/cgmanager.c
index 29c0e99..797e2ae 100644
--- a/src/lxc/cgmanager.c
+++ b/src/lxc/cgmanager.c
@@ -247,7 +247,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;
@@ -258,20 +257,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 {
--
1.8.5.3
More information about the lxc-devel
mailing list