driver.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package execdriver
  2. import (
  3. "os/exec"
  4. "syscall"
  5. "time"
  6. )
  7. type Driver interface {
  8. Start(c *Process) error
  9. Kill(c *Process, sig int) error
  10. Wait(id string, duration time.Duration) error // Wait on an out of process option - lxc ghosts
  11. Version() string
  12. }
  13. // Network settings of the container
  14. type Network struct {
  15. Gateway string
  16. IPAddress string
  17. IPPrefixLen int
  18. Mtu int
  19. }
  20. // Process wrapps an os/exec.Cmd to add more metadata
  21. type Process struct {
  22. exec.Cmd
  23. ID string
  24. Privileged bool
  25. User string
  26. Rootfs string // root fs of the container
  27. InitPath string // dockerinit
  28. Entrypoint string
  29. Arguments []string
  30. WorkingDir string
  31. ConfigPath string
  32. Tty bool
  33. Network *Network // if network is nil then networking is disabled
  34. SysInitPath string
  35. WaitLock chan struct{}
  36. WaitError error
  37. }
  38. func (c *Process) Pid() int {
  39. return c.Process.Pid
  40. }
  41. func (c *Process) GetExitCode() int {
  42. if c.ProcessState == nil {
  43. return -1
  44. }
  45. return c.ProcessState.Sys().(syscall.WaitStatus).ExitStatus()
  46. }