]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxc: lxc-unshare to remove its /cgroup/<pid> (V3)
authorMichel Normand <normand@fr.ibm.com>
Thu, 29 Apr 2010 08:03:59 +0000 (10:03 +0200)
committerDaniel Lezcano <dlezcano@fr.ibm.com>
Thu, 29 Apr 2010 08:03:59 +0000 (10:03 +0200)
this is required to avoid to fill /cgroup
with pid number each time lxc-unshare is called.

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
src/lxc/lxc_unshare.c

index 9414494c9e699f0db0fada3c5caa4116fd20d486..10654f743ef92ec9ecfc77344350063539a699ba 100644 (file)
@@ -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 <stdio.h>
+#undef _GNU_SOURCE
 #include <stdlib.h>
 #include <unistd.h>
 #include <libgen.h>
@@ -34,6 +36,8 @@
 
 #include <lxc/log.h>
 #include <lxc/namespace.h>
+#include <lxc/cgroup.h>
+#include <lxc/error.h>
 
 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);
+}