Add --pid-file to ctr

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby
2018-02-20 15:10:50 -05:00
parent 129167132c
commit d3a8055e2d
3 changed files with 38 additions and 1 deletions

View File

@@ -85,6 +85,10 @@ var ContainerFlags = []cli.Flag{
Name: "with-ns",
Usage: "specify existing Linux namespaces to join at container runtime (format '<nstype>:<path>')",
},
cli.StringFlag{
Name: "pid-file",
Usage: "file path to write the task's pid",
},
}
func loadSpec(path string, s *specs.Spec) error {
@@ -211,6 +215,11 @@ var Command = cli.Command{
return err
}
}
if context.IsSet("pid-file") {
if err := commands.WritePidFile(context.String("pid-file"), int(task.Pid())); err != nil {
return err
}
}
var con console.Console
if tty {
con = console.Current()