lxc: lxc-unshare to remove its /cgroup/<pid> (V3)

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>
This commit is contained in:
Michel Normand 2010-04-29 10:03:59 +02:00 committed by Daniel Lezcano
parent dcb7e5d5d2
commit b89885d896

View 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);
}