diff --git a/daemon/execdriver/native/driver.go b/daemon/execdriver/native/driver.go index 7cbb563ea7..1f27ef77b3 100644 --- a/daemon/execdriver/native/driver.go +++ b/daemon/execdriver/native/driver.go @@ -171,7 +171,7 @@ func (d *driver) Unpause(c *execdriver.Command) error { func (d *driver) Terminate(p *execdriver.Command) error { // lets check the start time for the process - started, err := d.readStartTime(p) + state, err := libcontainer.GetState(filepath.Join(d.root, p.ID)) if err != nil { // if we don't have the data on disk then we can assume the process is gone // because this is only removed after we know the process has stopped @@ -185,7 +185,7 @@ func (d *driver) Terminate(p *execdriver.Command) error { if err != nil { return err } - if started == currentStartTime { + if state.InitStartTime == currentStartTime { err = syscall.Kill(p.Process.Pid, 9) syscall.Wait4(p.Process.Pid, nil, 0, nil) } @@ -194,14 +194,6 @@ func (d *driver) Terminate(p *execdriver.Command) error { } -func (d *driver) readStartTime(p *execdriver.Command) (string, error) { - data, err := ioutil.ReadFile(filepath.Join(d.root, p.ID, "start")) - if err != nil { - return "", err - } - return string(data), nil -} - func (d *driver) Info(id string) execdriver.Info { return &info{ ID: id, diff --git a/daemon/execdriver/native/info.go b/daemon/execdriver/native/info.go index aef2f85c6b..693a455a41 100644 --- a/daemon/execdriver/native/info.go +++ b/daemon/execdriver/native/info.go @@ -1,8 +1,9 @@ package native import ( - "os" "path/filepath" + + "github.com/docker/libcontainer" ) type info struct { @@ -14,7 +15,7 @@ type info struct { // pid file for a container. If the file exists then the // container is currently running func (i *info) IsRunning() bool { - if _, err := os.Stat(filepath.Join(i.driver.root, i.ID, "pid")); err == nil { + if _, err := libcontainer.GetState(filepath.Join(i.driver.root, i.ID)); err == nil { return true } return false