]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
close also inherited fd in lxc-execute
authorMichel Normand <normand@fr.ibm.com>
Fri, 24 Jul 2009 13:25:45 +0000 (15:25 +0200)
committerDaniel Lezcano <dlezcano@fr.ibm.com>
Fri, 24 Jul 2009 13:25:45 +0000 (15:25 +0200)
This is a complement of previous patches d983b93c3ad860fa22ef760ae27a944d6000e35a
and af795875875de1855ee251ba530fbe2b53463f6e about inherited fd.

Here this is required for the lxc-execute that have a specific
lxc-init procress.

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

index 0a403c409991ee0a8ff590037422582c6dc2756c..2fee985866221b87cd5d92db99858cff28fee39d 100644 (file)
@@ -32,8 +32,7 @@
 #include <sys/mount.h>
 #define _GNU_SOURCE
 #include <getopt.h>
-#include "log.h"
-#include "error.h"
+#include "lxc.h"
 
 lxc_log_define(lxc_init, lxc);
 
@@ -59,6 +58,8 @@ static int mount_fs(const char *source, const char *target, const char *type)
                return -1;
        }
 
+       DEBUG("'%s' mounted on '%s'", source, target);
+
        return 0;
 }
 
@@ -66,6 +67,7 @@ static inline int setup_fs(void)
 {
        if (mount_fs("proc", "/proc", "proc"))
                return -1;
+
        if (mount_fs("shmfs", "/dev/shm", "tmpfs"))
                return -1;
 
@@ -114,11 +116,19 @@ int main(int argc, char *argv[])
                if (setup_fs())
                        exit(err);
 
+               NOTICE("about to exec '%s'", aargv[0]);
+
                execvp(aargv[0], aargv);
                ERROR("failed to exec: '%s' : %s", aargv[0], strerror(errno));
                exit(err);
        }
 
+       err = lxc_close_all_inherited_fd();
+       if (err) {
+               ERROR("unable to close inherited fds");
+               goto out;
+       }
+
        err = 0;
        for (;;) {
                int status;