daemon/kill.go
86528306
 package daemon
 
689c4e60
 import "syscall"
86528306
 
 // 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.
3cb75190
 func (daemon *Daemon) ContainerKill(name string, sig uint64) error {
d25a6537
 	container, err := daemon.Get(name)
 	if err != nil {
c79b9bab
 		return err
d25a6537
 	}
 
 	// 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 {
689c4e60
 			return err
86528306
 		}
 	} else {
d25a6537
 		// Otherwise, just send the requested signal
 		if err := container.KillSig(int(sig)); err != nil {
689c4e60
 			return err
d25a6537
 		}
86528306
 	}
c79b9bab
 	return nil
86528306
 }