Skip to content

Commit

Permalink
new-api: return the Running state only if the init process is alive
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Vagin <[email protected]>
  • Loading branch information
avagin committed Dec 23, 2014
1 parent 1a380ac commit 13841ef
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion linux_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,27 @@ func (c *linuxContainer) Config() *configs.Config {
}

func (c *linuxContainer) RunState() (configs.RunState, error) {
return configs.Destroyed, nil // FIXME return a real state
if c.state.InitPid <= 0 {
return configs.Destroyed, nil
}

// return Running if the init process is alive
err := syscall.Kill(c.state.InitPid, 0)
if err != nil {
errn, y := err.(syscall.Errno)
if !y {
return 0, err
}

if errn == syscall.ESRCH {
return configs.Destroyed, nil
}
return 0, err
}

//FIXME get a cgroup state to check other states

return configs.Running, nil
}

func (c *linuxContainer) Processes() ([]int, error) {
Expand Down

0 comments on commit 13841ef

Please sign in to comment.