Merge pull request #646 from crosbymichael/pid-host-block

Destroy container along with processes before stdio
This commit is contained in:
Alexander Morozov
2016-03-17 09:51:59 -07:00
7 changed files with 116 additions and 51 deletions
+13 -13
View File
@@ -43,6 +43,10 @@ is a directory with a specification file and a root filesystem.`,
Value: "",
Usage: "specify the file to write the process id to",
},
cli.BoolFlag{
Name: "no-subreaper",
Usage: "disable the use of the subreaper used to reap reparented processes",
},
},
Action: func(context *cli.Context) {
bundle := context.String("bundle")
@@ -102,24 +106,20 @@ func startContainer(context *cli.Context, spec *specs.Spec) (int, error) {
if err != nil {
return -1, err
}
// ensure that the container is always removed if we were the process
// that created it.
detach := context.Bool("detach")
if !detach {
defer destroy(container)
}
// Support on-demand socket activation by passing file descriptors into the container init process.
listenFDs := []*os.File{}
if os.Getenv("LISTEN_FDS") != "" {
listenFDs = activation.Files(false)
}
status, err := runProcess(container, &spec.Process, listenFDs, context.String("console"), context.String("pid-file"), detach)
if err != nil {
destroy(container)
return -1, err
r := &runner{
enableSubreaper: !context.Bool("no-subreaper"),
shouldDestroy: true,
container: container,
listenFDs: listenFDs,
console: context.String("console"),
detach: detach,
pidFile: context.String("pid-file"),
}
return status, nil
return r.run(&spec.Process)
}