From 0698777a36186afe4790269f935bffa53e464ece Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Fri, 25 Mar 2016 11:15:09 -0700 Subject: [PATCH] Move lockthread to package level Move this to be one of the first things that is done in the main if we are executing the init. Signed-off-by: Michael Crosby --- start.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/start.go b/start.go index a3015ab8..277daa48 100644 --- a/start.go +++ b/start.go @@ -85,12 +85,17 @@ command(s) that get executed on start, edit the args parameter of the spec. See }, } +func init() { + if len(os.Args) > 1 && os.Args[1] == "init" { + runtime.GOMAXPROCS(1) + runtime.LockOSThread() + } +} + var initCommand = cli.Command{ Name: "init", Usage: `initialize the namespaces and launch the process (do not call it outside of runc)`, Action: func(context *cli.Context) { - runtime.GOMAXPROCS(1) - runtime.LockOSThread() factory, _ := libcontainer.New("") if err := factory.StartInitialization(); err != nil { // as the error is sent back to the parent there is no need to log