From: Michel Normand Date: Thu, 29 Apr 2010 08:03:59 +0000 (+0200) Subject: lxc: lxc-unshare to remove its /cgroup/ (V3) X-Git-Tag: lxc-0.7.0~99 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b89885d89696cdb79495b12b97d80d02e1c3f3fc;p=thirdparty%2Flxc.git lxc: lxc-unshare to remove its /cgroup/ (V3) this is required to avoid to fill /cgroup with pid number each time lxc-unshare is called. Signed-off-by: Michel Normand Signed-off-by: Daniel Lezcano --- diff --git a/src/lxc/lxc_unshare.c b/src/lxc/lxc_unshare.c index 9414494c9..10654f743 100644 --- a/src/lxc/lxc_unshare.c +++ b/src/lxc/lxc_unshare.c @@ -20,7 +20,9 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#define _GNU_SOURCE #include +#undef _GNU_SOURCE #include #include #include @@ -34,6 +36,8 @@ #include #include +#include +#include lxc_log_define(lxc_unshare_ui, lxc); @@ -154,6 +158,7 @@ int main(int argc, char *argv[]) { int opt, status; int ret; + char *pid_name; char *namespaces = NULL; char **args; int flags = 0; @@ -200,6 +205,12 @@ int main(int argc, char *argv[]) return -1; } - return status; -} + if (!asprintf(&pid_name, "%d", pid)) { + ERROR("pid_name: failed to allocate memory"); + return -1; + } + lxc_unlink_nsgroup(pid_name); + free(pid_name); + return lxc_error_set_and_log(pid, status); +}