summaryrefslogtreecommitdiffhomepage
path: root/runsc/cmd/kill.go
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2018-09-27 15:00:03 -0700
committerShentubot <shentubot@google.com>2018-09-27 15:00:58 -0700
commit491faac03b2815ca1bc9b5425c1b3f6291468e20 (patch)
tree0a8f0c1ad99c3d8660f36802132ecd9386c54518 /runsc/cmd/kill.go
parent68ac2ad1e1f16e65d9d1318d6827edf8487578d0 (diff)
Implement 'runsc kill --all'
In order to implement kill --all correctly, the Sentry needs to track all tasks that belong to a given container. This change introduces ContainerID to the task, that gets inherited by all children. 'kill --all' then iterates over all tasks comparing the ContainerID field to find all processes that need to be signalled. PiperOrigin-RevId: 214841768 Change-Id: I693b2374be8692d88cc441ef13a0ae34abf73ac6
Diffstat (limited to 'runsc/cmd/kill.go')
-rw-r--r--runsc/cmd/kill.go15
1 files changed, 7 insertions, 8 deletions
diff --git a/runsc/cmd/kill.go b/runsc/cmd/kill.go
index 6fa5674f1..af709bc71 100644
--- a/runsc/cmd/kill.go
+++ b/runsc/cmd/kill.go
@@ -29,7 +29,9 @@ import (
)
// Kill implements subcommands.Command for the "kill" command.
-type Kill struct{}
+type Kill struct {
+ all bool
+}
// Name implements subcommands.Command.Name.
func (*Kill) Name() string {
@@ -47,15 +49,12 @@ func (*Kill) Usage() string {
}
// SetFlags implements subcommands.Command.SetFlags.
-func (*Kill) SetFlags(f *flag.FlagSet) {
- // TODO: Implement this flag. It is defined here just to
- // prevent runsc from crashing if it is passed.
- var all bool
- f.BoolVar(&all, "all", false, "send the specified signal to all processes inside the container")
+func (k *Kill) SetFlags(f *flag.FlagSet) {
+ f.BoolVar(&k.all, "all", false, "send the specified signal to all processes inside the container")
}
// Execute implements subcommands.Command.Execute.
-func (*Kill) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) subcommands.ExitStatus {
+func (k *Kill) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) subcommands.ExitStatus {
if f.NArg() == 0 || f.NArg() > 2 {
f.Usage()
return subcommands.ExitUsageError
@@ -83,7 +82,7 @@ func (*Kill) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) su
}
// TODO: Distinguish between already-exited containers and
// genuine errors.
- if err := c.Signal(sig); err != nil {
+ if err := c.Signal(sig, k.all); err != nil {
Fatalf("%v", err)
}
return subcommands.ExitSuccess