Use new libcontainer.State API

Docker-DCO-1.1-Signed-off-by: Tibor Vass <teabee89@gmail.com> (github: tiborvass)
This commit is contained in:
Tibor Vass 2014-06-30 18:27:15 -04:00
Родитель 36c78c9172
Коммит 262d45e0fe
2 изменённых файлов: 5 добавлений и 12 удалений

Просмотреть файл

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

Просмотреть файл

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