mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
8232312c1e
Move some calls to container.LogEvent down lower so that there's less of a chance of them being missed. Also add a few more events that appear to have been missed. Added testcases for new events: commit, copy, resize, attach, rename, top Signed-off-by: Doug Davis <dug@us.ibm.com>
30 lines
843 B
Go
30 lines
843 B
Go
package daemon
|
|
|
|
import (
|
|
"fmt"
|
|
"syscall"
|
|
)
|
|
|
|
// ContainerKill send signal to the container
|
|
// If no signal is given (sig 0), then Kill with SIGKILL and wait
|
|
// for the container to exit.
|
|
// If a signal is given, then just send it to the container and return.
|
|
func (daemon *Daemon) ContainerKill(name string, sig uint64) error {
|
|
container, err := daemon.Get(name)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
// If no signal is passed, or SIGKILL, perform regular Kill (SIGKILL + wait())
|
|
if sig == 0 || syscall.Signal(sig) == syscall.SIGKILL {
|
|
if err := container.Kill(); err != nil {
|
|
return fmt.Errorf("Cannot kill container %s: %s", name, err)
|
|
}
|
|
} else {
|
|
// Otherwise, just send the requested signal
|
|
if err := container.KillSig(int(sig)); err != nil {
|
|
return fmt.Errorf("Cannot kill container %s: %s", name, err)
|
|
}
|
|
}
|
|
return nil
|
|
}
|