Ensure thread is locked in sysinit for docker

Signed-off-by: Michael Crosby <michael@docker.com>
This commit is contained in:
Michael Crosby 2014-08-04 11:41:59 -07:00
parent 22f373aeda
commit cd6b903825
1 changed files with 5 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"log" "log"
"os" "os"
"runtime"
"github.com/docker/docker/daemon/execdriver" "github.com/docker/docker/daemon/execdriver"
_ "github.com/docker/docker/daemon/execdriver/lxc" _ "github.com/docker/docker/daemon/execdriver/lxc"
@ -23,6 +24,10 @@ func executeProgram(args *execdriver.InitArgs) error {
// This code is run INSIDE the container and is responsible for setting // This code is run INSIDE the container and is responsible for setting
// up the environment before running the actual process // up the environment before running the actual process
func SysInit() { func SysInit() {
// The very first thing that we should do is lock the thread so that other
// system level options will work and not have issues, i.e. setns
runtime.LockOSThread()
if len(os.Args) <= 1 { if len(os.Args) <= 1 {
fmt.Println("You should not invoke dockerinit manually") fmt.Println("You should not invoke dockerinit manually")
os.Exit(1) os.Exit(1)