diff --git a/execdriver/lxc/driver.go b/execdriver/lxc/driver.go index 765a52ee43..b398cb1a37 100644 --- a/execdriver/lxc/driver.go +++ b/execdriver/lxc/driver.go @@ -168,6 +168,9 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba // Poll lxc for RUNNING status pid, err := d.waitForStart(c, waitLock) if err != nil { + if c.Process != nil { + c.Process.Kill() + } return -1, err } c.ContainerPid = pid diff --git a/server.go b/server.go index 48bb6f9805..d6a4036faf 100644 --- a/server.go +++ b/server.go @@ -2384,7 +2384,13 @@ func (srv *Server) IsRunning() bool { } func (srv *Server) Close() error { + if srv == nil { + return nil + } srv.SetRunning(false) + if srv.runtime == nil { + return nil + } return srv.runtime.Close() }