2014-07-16 19:39:15 -04:00
|
|
|
// +build linux,cgo
|
2014-07-14 15:49:50 -04:00
|
|
|
|
2014-02-25 00:21:35 -05:00
|
|
|
package native
|
|
|
|
|
|
|
|
import (
|
2014-07-01 19:14:22 -04:00
|
|
|
"os"
|
2014-02-25 00:21:35 -05:00
|
|
|
"path/filepath"
|
2014-06-30 18:27:15 -04:00
|
|
|
|
|
|
|
"github.com/docker/libcontainer"
|
2014-02-25 00:21:35 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
type info struct {
|
|
|
|
ID string
|
|
|
|
driver *driver
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsRunning is determined by looking for the
|
2014-02-26 22:19:14 -05:00
|
|
|
// pid file for a container. If the file exists then the
|
2014-02-25 00:21:35 -05:00
|
|
|
// container is currently running
|
|
|
|
func (i *info) IsRunning() bool {
|
2014-06-30 18:27:15 -04:00
|
|
|
if _, err := libcontainer.GetState(filepath.Join(i.driver.root, i.ID)); err == nil {
|
2014-02-25 00:21:35 -05:00
|
|
|
return true
|
|
|
|
}
|
2014-07-01 19:14:22 -04:00
|
|
|
// TODO: Remove this part for version 1.2.0
|
|
|
|
// This is added only to ensure smooth upgrades from pre 1.1.0 to 1.1.0
|
|
|
|
if _, err := os.Stat(filepath.Join(i.driver.root, i.ID, "pid")); err == nil {
|
|
|
|
return true
|
|
|
|
}
|
2014-02-25 00:21:35 -05:00
|
|
|
return false
|
|
|
|
}
|