1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

exexdriver: Make Command.GetExitCode an internal call

This code only works for backends that directly spawn the child
via the Command. It will not work for the libvirt backend. So
we move this code into the individual backends that need it.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
This commit is contained in:
Alexander Larsson 2014-01-28 11:16:02 +01:00
parent ffdc2d2657
commit 9ad70528b7
3 changed files with 21 additions and 12 deletions

View file

@ -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 {

View file

@ -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()
}

View file

@ -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 {