github.com/circular-dark/docker@v1.7.0/daemon/kill.go (about) 1 package daemon 2 3 import ( 4 "fmt" 5 "syscall" 6 ) 7 8 // ContainerKill send signal to the container 9 // If no signal is given (sig 0), then Kill with SIGKILL and wait 10 // for the container to exit. 11 // If a signal is given, then just send it to the container and return. 12 func (daemon *Daemon) ContainerKill(name string, sig uint64) error { 13 container, err := daemon.Get(name) 14 if err != nil { 15 return err 16 } 17 18 // If no signal is passed, or SIGKILL, perform regular Kill (SIGKILL + wait()) 19 if sig == 0 || syscall.Signal(sig) == syscall.SIGKILL { 20 if err := container.Kill(); err != nil { 21 return fmt.Errorf("Cannot kill container %s: %s", name, err) 22 } 23 } else { 24 // Otherwise, just send the requested signal 25 if err := container.KillSig(int(sig)); err != nil { 26 return fmt.Errorf("Cannot kill container %s: %s", name, err) 27 } 28 } 29 container.LogEvent("kill") 30 return nil 31 }