From d3bae131d6fa10dd1c25077204bf2c3274a3b8cc Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Mon, 13 Jan 2014 17:55:16 -0800 Subject: [PATCH] Make sure proc is umounted for chroot driver within init Docker-DCO-1.1-Signed-off-by: Michael Crosby (github: crosbymichael) --- sysinit/sysinit.go | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/sysinit/sysinit.go b/sysinit/sysinit.go index 73349379fb..6701717fe3 100644 --- a/sysinit/sysinit.go +++ b/sysinit/sysinit.go @@ -208,11 +208,10 @@ func executeProgram(args *DockerInitArgs) error { return err } } else if args.driver == "chroot" { - // TODO: @crosbymichael @creack how do we unmount this after the - // process exists? if err := setupMounts(args); err != nil { return err } + defer mount.ForceUnmount("proc") } path, err := exec.LookPath(args.args[0]) @@ -221,11 +220,22 @@ func executeProgram(args *DockerInitArgs) error { os.Exit(127) } - if err := syscall.Exec(path, args.args, os.Environ()); err != nil { - return fmt.Errorf("dockerinit unable to execute %s - %s", path, err) - } + if args.driver == "lxc" { + if err := syscall.Exec(path, args.args, os.Environ()); err != nil { + panic(err) + } + // Will never reach + } else if args.driver == "chroot" { + cmd := exec.Command(path, args.args[1:]...) + + cmd.Stderr = os.Stderr + cmd.Stdout = os.Stdout + cmd.Stdin = os.Stdin + + return cmd.Run() + } + panic("Should not be here") - // Will never reach here return nil }