github.com/zhuohuang-hust/src-cbuild@v0.0.0-20230105071821-c7aab3e7c840/mergeCode/runc/main_unix.go (about) 1 // +build linux 2 3 package main 4 5 import ( 6 "os" 7 "runtime" 8 9 "github.com/opencontainers/runc/libcontainer" 10 _ "github.com/opencontainers/runc/libcontainer/nsenter" 11 "github.com/urfave/cli" 12 ) 13 14 func init() { 15 if len(os.Args) > 1 && os.Args[1] == "init" { 16 runtime.GOMAXPROCS(1) 17 runtime.LockOSThread() 18 } 19 } 20 21 var initCommand = cli.Command{ 22 Name: "init", 23 Usage: `initialize the namespaces and launch the process (do not call it outside of runc)`, 24 Action: func(context *cli.Context) error { 25 factory, _ := libcontainer.New("") 26 if err := factory.StartInitialization(); err != nil { 27 // as the error is sent back to the parent there is no need to log 28 // or write it to stderr because the parent process will handle this 29 os.Exit(1) 30 } 31 panic("libcontainer: container init failed to exec") 32 }, 33 }