Browse code

Allow to kill container after docker server restarts

Guillaume J. Charmes authored on 2013/04/20 04:12:30
Showing 1 changed files
... ...
@@ -614,7 +614,7 @@ func (container *Container) monitor() {
614 614
 }
615 615
 
616 616
 func (container *Container) kill() error {
617
-	if !container.State.Running || container.cmd == nil {
617
+	if !container.State.Running {
618 618
 		return nil
619 619
 	}
620 620
 
... ...
@@ -626,6 +626,9 @@ func (container *Container) kill() error {
626 626
 
627 627
 	// 2. Wait for the process to die, in last resort, try to kill the process directly
628 628
 	if err := container.WaitTimeout(10 * time.Second); err != nil {
629
+		if container.cmd == nil {
630
+			return fmt.Errorf("lxc-kill failed, impossible to kill the container %s", container.Id)
631
+		}
629 632
 		log.Printf("Container %s failed to exit within 10 seconds of lxc SIGKILL - trying direct SIGKILL", container.Id)
630 633
 		if err := container.cmd.Process.Kill(); err != nil {
631 634
 			return err