add support to kill container process by pid

This adds support for signalling a container process by pid.

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>

make Ps more extensible

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>

ps: windows support

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
This commit is contained in:
Evan Hazlett
2017-05-09 15:50:02 -04:00
parent fae11b6673
commit ef158f8b5e
14 changed files with 1523 additions and 145 deletions

View File

@@ -16,6 +16,11 @@ var killCommand = cli.Command{
Name: "id",
Usage: "id of the container",
},
cli.IntFlag{
Name: "pid",
Usage: "pid to kill",
Value: 0,
},
cli.BoolFlag{
Name: "all, a",
Usage: "send signal to all processes inside the container",
@@ -37,14 +42,29 @@ var killCommand = cli.Command{
return err
}
containers, err := getExecutionService(context)
if err != nil {
return err
pid := context.Int("pid")
all := context.Bool("all")
if pid > 0 && all {
return errors.New("enter a pid or all; not both")
}
killRequest := &execution.KillRequest{
ID: id,
Signal: uint32(signal),
All: context.Bool("all"),
PidOrAll: &execution.KillRequest_Pid{
Pid: uint32(pid),
},
}
if all {
killRequest.PidOrAll = &execution.KillRequest_All{
All: true,
}
}
containers, err := getExecutionService(context)
if err != nil {
return err
}
_, err = containers.Kill(gocontext.Background(), killRequest)
if err != nil {