|
@@ -561,6 +561,12 @@ func (container *Container) kill() error {
|
|
func (container *Container) Kill() error {
|
|
func (container *Container) Kill() error {
|
|
container.State.lock()
|
|
container.State.lock()
|
|
defer container.State.unlock()
|
|
defer container.State.unlock()
|
|
|
|
+ if !container.State.Running {
|
|
|
|
+ return nil
|
|
|
|
+ }
|
|
|
|
+ if container.State.Ghost {
|
|
|
|
+ return fmt.Errorf("Impossible to kill ghost containers")
|
|
|
|
+ }
|
|
return container.kill()
|
|
return container.kill()
|
|
}
|
|
}
|
|
|
|
|
|
@@ -570,6 +576,9 @@ func (container *Container) Stop() error {
|
|
if !container.State.Running {
|
|
if !container.State.Running {
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
+ if container.State.Ghost {
|
|
|
|
+ return fmt.Errorf("Impossible to stop ghost containers")
|
|
|
|
+ }
|
|
|
|
|
|
// 1. Send a SIGTERM
|
|
// 1. Send a SIGTERM
|
|
if output, err := exec.Command("lxc-kill", "-n", container.Id, "15").CombinedOutput(); err != nil {
|
|
if output, err := exec.Command("lxc-kill", "-n", container.Id, "15").CombinedOutput(); err != nil {
|