ソースを参照

Use new libcontainer.State API

Docker-DCO-1.1-Signed-off-by: Tibor Vass <teabee89@gmail.com> (github: tiborvass)
Tibor Vass 11 年 前
コミット
262d45e0fe
2 ファイル変更5 行追加12 行削除
  1. 2 10
      daemon/execdriver/native/driver.go
  2. 3 2
      daemon/execdriver/native/info.go

+ 2 - 10
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,

+ 3 - 2
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