diff --git a/src/lxc/cgroup.c b/src/lxc/cgroup.c index 15f021239..69ba4e5d1 100644 --- a/src/lxc/cgroup.c +++ b/src/lxc/cgroup.c @@ -419,9 +419,12 @@ static int lxc_one_cgroup_create(const char *name, } /* if cgparent does not exist, create it */ - if (access(cgparent, F_OK) && mkdir(cgparent, 0755)) { - SYSERROR("failed to create '%s' directory", cgparent); - return -1; + if (access(cgparent, F_OK)) { + ret = mkdir(cgparent, 0755); + if (ret == -1 && errno == EEXIST) { + SYSERROR("failed to create '%s' directory", cgparent); + return -1; + } } /*