diff --git a/container.go b/container.go index d8ff8488d0..702d94e391 100644 --- a/container.go +++ b/container.go @@ -1115,7 +1115,7 @@ func (container *Container) monitor(callback execdriver.StartCallback) error { if container.process == nil { // This happends when you have a GHOST container with lxc - err = container.runtime.Wait(container, 0) + err = container.runtime.WaitGhost(container) } else { exitCode, err = container.runtime.Run(container, callback) } diff --git a/execdriver/chroot/driver.go b/execdriver/chroot/driver.go index e5dc69131c..6244d2a93f 100644 --- a/execdriver/chroot/driver.go +++ b/execdriver/chroot/driver.go @@ -3,7 +3,6 @@ package chroot import ( "github.com/dotcloud/docker/execdriver" "os/exec" - "time" ) type driver struct { @@ -55,8 +54,8 @@ func (d *driver) Kill(p *execdriver.Process, sig int) error { return p.Process.Kill() } -func (d *driver) Wait(id string, duration time.Duration) error { - panic("No Implemented") +func (d *driver) Wait(id string) error { + panic("Not Implemented") } func (d *driver) Version() string { diff --git a/execdriver/driver.go b/execdriver/driver.go index 8f566324ae..d68123d9ba 100644 --- a/execdriver/driver.go +++ b/execdriver/driver.go @@ -4,7 +4,6 @@ import ( "errors" "os/exec" "syscall" - "time" ) var ( @@ -18,7 +17,7 @@ type Driver interface { Run(c *Process, startCallback StartCallback) (int, error) // Run executes the process and blocks until the process exits and returns the exit code Kill(c *Process, sig int) error // TODO: @crosbymichael @creack wait should probably return the exit code - Wait(id string, duration time.Duration) error // Wait on an out of process...process - lxc ghosts + Wait(id string) error // Wait on an out of process...process - lxc ghosts Version() string Name() string } diff --git a/execdriver/lxc/driver.go b/execdriver/lxc/driver.go index 3b4d385cac..3939841320 100644 --- a/execdriver/lxc/driver.go +++ b/execdriver/lxc/driver.go @@ -133,24 +133,17 @@ func (d *driver) Kill(c *execdriver.Process, sig int) error { return d.kill(c, sig) } -func (d *driver) Wait(id string, duration time.Duration) error { - var ( - killer bool - done = d.waitLxc(id, &killer) - ) - - if duration > 0 { - select { - case err := <-done: +func (d *driver) Wait(id string) error { + for { + output, err := exec.Command("lxc-info", "-n", id).CombinedOutput() + if err != nil { return err - case <-time.After(duration): - killer = true - return execdriver.ErrWaitTimeoutReached } - } else { - return <-done + if !strings.Contains(string(output), "RUNNING") { + return nil + } + time.Sleep(500 * time.Millisecond) } - return nil } func (d *driver) Version() string { @@ -207,25 +200,6 @@ func (d *driver) waitForStart(c *execdriver.Process, waitLock chan struct{}) err return execdriver.ErrNotRunning } -func (d *driver) waitLxc(id string, kill *bool) <-chan error { - done := make(chan error) - go func() { - for *kill { - output, err := exec.Command("lxc-info", "-n", id).CombinedOutput() - if err != nil { - done <- err - return - } - if !strings.Contains(string(output), "RUNNING") { - done <- err - return - } - time.Sleep(500 * time.Millisecond) - } - }() - return done -} - func (d *driver) getInfo(c *execdriver.Process) ([]byte, error) { return exec.Command("lxc-info", "-s", "-n", c.ID).CombinedOutput() } diff --git a/runtime.go b/runtime.go index ec32f75456..8b7d5d3494 100644 --- a/runtime.go +++ b/runtime.go @@ -849,8 +849,8 @@ func (runtime *Runtime) Kill(c *Container, sig int) error { return runtime.execDriver.Kill(c.process, sig) } -func (runtime *Runtime) Wait(c *Container, duration time.Duration) error { - return runtime.execDriver.Wait(c.ID, duration) +func (runtime *Runtime) WaitGhost(c *Container) error { + return runtime.execDriver.Wait(c.ID) } // Nuke kills all containers then removes all content