mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Use new libcontainer.State API
Docker-DCO-1.1-Signed-off-by: Tibor Vass <teabee89@gmail.com> (github: tiborvass)
This commit is contained in:
parent
36c78c9172
commit
262d45e0fe
2 changed files with 5 additions and 12 deletions
|
@ -171,7 +171,7 @@ func (d *driver) Unpause(c *execdriver.Command) error {
|
||||||
|
|
||||||
func (d *driver) Terminate(p *execdriver.Command) error {
|
func (d *driver) Terminate(p *execdriver.Command) error {
|
||||||
// lets check the start time for the process
|
// 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 err != nil {
|
||||||
// if we don't have the data on disk then we can assume the process is gone
|
// 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
|
// 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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if started == currentStartTime {
|
if state.InitStartTime == currentStartTime {
|
||||||
err = syscall.Kill(p.Process.Pid, 9)
|
err = syscall.Kill(p.Process.Pid, 9)
|
||||||
syscall.Wait4(p.Process.Pid, nil, 0, nil)
|
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 {
|
func (d *driver) Info(id string) execdriver.Info {
|
||||||
return &info{
|
return &info{
|
||||||
ID: id,
|
ID: id,
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package native
|
package native
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/docker/libcontainer"
|
||||||
)
|
)
|
||||||
|
|
||||||
type info struct {
|
type info struct {
|
||||||
|
@ -14,7 +15,7 @@ type info struct {
|
||||||
// pid file for a container. If the file exists then the
|
// pid file for a container. If the file exists then the
|
||||||
// container is currently running
|
// container is currently running
|
||||||
func (i *info) IsRunning() bool {
|
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 true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue