Skip to content

Commit

Permalink
[PATCH cgmanager chown: don't do a gratuitous fork
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
hallyn authored and stgraber committed Jan 29, 2014
1 parent 7a435f9 commit beebf12
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions src/lxc/cgmanager.c
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down

0 comments on commit beebf12

Please sign in to comment.