diff options
Diffstat (limited to 'runsc/cmd')
-rw-r--r-- | runsc/cmd/kill.go | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/runsc/cmd/kill.go b/runsc/cmd/kill.go index dcb2988e3..7a98d10a2 100644 --- a/runsc/cmd/kill.go +++ b/runsc/cmd/kill.go @@ -31,6 +31,7 @@ import ( // Kill implements subcommands.Command for the "kill" command. type Kill struct { all bool + pid int } // Name implements subcommands.Command.Name. @@ -51,6 +52,7 @@ func (*Kill) Usage() string { // SetFlags implements subcommands.Command.SetFlags. func (k *Kill) SetFlags(f *flag.FlagSet) { f.BoolVar(&k.all, "all", false, "send the specified signal to all processes inside the container") + f.IntVar(&k.pid, "pid", 0, "send the specified signal to a specific process") } // Execute implements subcommands.Command.Execute. @@ -63,6 +65,10 @@ func (k *Kill) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) id := f.Arg(0) conf := args[0].(*boot.Config) + if k.pid != 0 && k.all { + Fatalf("it is invalid to specify both --all and --pid") + } + c, err := container.Load(conf.RootDir, id) if err != nil { Fatalf("error loading container: %v", err) @@ -80,8 +86,15 @@ func (k *Kill) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) if err != nil { Fatalf("%v", err) } - if err := c.Signal(sig, k.all); err != nil { - Fatalf("%v", err) + + if k.pid != 0 { + if err := c.SignalProcess(sig, int32(k.pid)); err != nil { + Fatalf("failed to signal pid %d: %v", k.pid, err) + } + } else { + if err := c.SignalContainer(sig, k.all); err != nil { + Fatalf("%v", err) + } } return subcommands.ExitSuccess } |