diff --git a/execdriver/chroot/driver.go b/execdriver/chroot/driver.go index 4b2e02904e..7848cfc4be 100644 --- a/execdriver/chroot/driver.go +++ b/execdriver/chroot/driver.go @@ -6,6 +6,7 @@ import ( "github.com/dotcloud/docker/pkg/mount" "os" "os/exec" + "syscall" ) const ( @@ -67,7 +68,16 @@ func (d *driver) Run(c *execdriver.Command, startCallback execdriver.StartCallba } err = c.Wait() - return c.GetExitCode(), err + return getExitCode(c), err +} + +/// Return the exit code of the process +// if the process has not exited -1 will be returned +func getExitCode(c *execdriver.Command) int { + if c.ProcessState == nil { + return -1 + } + return c.ProcessState.Sys().(syscall.WaitStatus).ExitStatus() } func (d *driver) Kill(p *execdriver.Command, sig int) error { diff --git a/execdriver/driver.go b/execdriver/driver.go index 511e9e80c6..9b352c379f 100644 --- a/execdriver/driver.go +++ b/execdriver/driver.go @@ -3,7 +3,6 @@ package execdriver import ( "errors" "os/exec" - "syscall" ) var ( @@ -109,12 +108,3 @@ func (c *Command) Pid() int { } return c.Process.Pid } - -// Return the exit code of the process -// if the process has not exited -1 will be returned -func (c *Command) GetExitCode() int { - if c.ProcessState == nil { - return -1 - } - return c.ProcessState.Sys().(syscall.WaitStatus).ExitStatus() -} diff --git a/execdriver/lxc/driver.go b/execdriver/lxc/driver.go index 0e64dfd968..0d3454f2b7 100644 --- a/execdriver/lxc/driver.go +++ b/execdriver/lxc/driver.go @@ -169,7 +169,16 @@ func (d *driver) Run(c *execdriver.Command, startCallback execdriver.StartCallba <-waitLock - return c.GetExitCode(), waitErr + return getExitCode(c), waitErr +} + +/// Return the exit code of the process +// if the process has not exited -1 will be returned +func getExitCode(c *execdriver.Command) int { + if c.ProcessState == nil { + return -1 + } + return c.ProcessState.Sys().(syscall.WaitStatus).ExitStatus() } func (d *driver) Kill(c *execdriver.Command, sig int) error {