runsc: allow kill --all when container is in stopped state.

PiperOrigin-RevId: 215009105
Change-Id: I1ab12eddf7694c4db98f6dafca9dae352a33f7c4
This commit is contained in:
Lantao Liu
2018-09-28 15:53:25 -07:00
committed by Shentubot
parent 49ff81a42b
commit f21dde5666
+9 -1
View File
@@ -472,9 +472,17 @@ func (c *Container) WaitPID(pid int32, clearStatus bool) (syscall.WaitStatus, er
// TODO: Distinguish different error types.
func (c *Container) Signal(sig syscall.Signal, all bool) error {
log.Debugf("Signal container %q: %v", c.ID, sig)
if err := c.requireStatus("signal", Running); err != nil {
// Signaling container in Stopped state is allowed. When all=false,
// an error will be returned anyway; when all=true, this allows
// sending signal to other processes inside the container even
// after the init process exits. This is especially useful for
// container cleanup.
if err := c.requireStatus("signal", Running, Stopped); err != nil {
return err
}
if !c.isSandboxRunning() {
return fmt.Errorf("container is not running")
}
// TODO: Query the container for its state, then save it.
return c.Sandbox.Signal(c.ID, sig, all)
}