Docker-DCO-1.1-Signed-off-by: Tibor Vass <teabee89@gmail.com> (github: tiborvass)
| ... | ... |
@@ -171,7 +171,7 @@ func (d *driver) Unpause(c *execdriver.Command) error {
|
| 171 | 171 |
|
| 172 | 172 |
func (d *driver) Terminate(p *execdriver.Command) error {
|
| 173 | 173 |
// lets check the start time for the process |
| 174 |
- started, err := d.readStartTime(p) |
|
| 174 |
+ state, err := libcontainer.GetState(filepath.Join(d.root, p.ID)) |
|
| 175 | 175 |
if err != nil {
|
| 176 | 176 |
// if we don't have the data on disk then we can assume the process is gone |
| 177 | 177 |
// because this is only removed after we know the process has stopped |
| ... | ... |
@@ -185,7 +185,7 @@ func (d *driver) Terminate(p *execdriver.Command) error {
|
| 185 | 185 |
if err != nil {
|
| 186 | 186 |
return err |
| 187 | 187 |
} |
| 188 |
- if started == currentStartTime {
|
|
| 188 |
+ if state.InitStartTime == currentStartTime {
|
|
| 189 | 189 |
err = syscall.Kill(p.Process.Pid, 9) |
| 190 | 190 |
syscall.Wait4(p.Process.Pid, nil, 0, nil) |
| 191 | 191 |
} |
| ... | ... |
@@ -194,14 +194,6 @@ func (d *driver) Terminate(p *execdriver.Command) error {
|
| 194 | 194 |
|
| 195 | 195 |
} |
| 196 | 196 |
|
| 197 |
-func (d *driver) readStartTime(p *execdriver.Command) (string, error) {
|
|
| 198 |
- data, err := ioutil.ReadFile(filepath.Join(d.root, p.ID, "start")) |
|
| 199 |
- if err != nil {
|
|
| 200 |
- return "", err |
|
| 201 |
- } |
|
| 202 |
- return string(data), nil |
|
| 203 |
-} |
|
| 204 |
- |
|
| 205 | 197 |
func (d *driver) Info(id string) execdriver.Info {
|
| 206 | 198 |
return &info{
|
| 207 | 199 |
ID: id, |
| ... | ... |
@@ -1,8 +1,9 @@ |
| 1 | 1 |
package native |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
- "os" |
|
| 5 | 4 |
"path/filepath" |
| 5 |
+ |
|
| 6 |
+ "github.com/docker/libcontainer" |
|
| 6 | 7 |
) |
| 7 | 8 |
|
| 8 | 9 |
type info struct {
|
| ... | ... |
@@ -14,7 +15,7 @@ type info struct {
|
| 14 | 14 |
// pid file for a container. If the file exists then the |
| 15 | 15 |
// container is currently running |
| 16 | 16 |
func (i *info) IsRunning() bool {
|
| 17 |
- if _, err := os.Stat(filepath.Join(i.driver.root, i.ID, "pid")); err == nil {
|
|
| 17 |
+ if _, err := libcontainer.GetState(filepath.Join(i.driver.root, i.ID)); err == nil {
|
|
| 18 | 18 |
return true |
| 19 | 19 |
} |
| 20 | 20 |
return false |