info.go 665 B

123456789101112131415161718192021222324252627282930
  1. // +build linux,cgo
  2. package native
  3. import (
  4. "os"
  5. "path/filepath"
  6. "github.com/docker/libcontainer"
  7. )
  8. type info struct {
  9. ID string
  10. driver *driver
  11. }
  12. // IsRunning is determined by looking for the
  13. // pid file for a container. If the file exists then the
  14. // container is currently running
  15. func (i *info) IsRunning() bool {
  16. if _, err := libcontainer.GetState(filepath.Join(i.driver.root, i.ID)); err == nil {
  17. return true
  18. }
  19. // TODO: Remove this part for version 1.2.0
  20. // This is added only to ensure smooth upgrades from pre 1.1.0 to 1.1.0
  21. if _, err := os.Stat(filepath.Join(i.driver.root, i.ID, "pid")); err == nil {
  22. return true
  23. }
  24. return false
  25. }