From b6e23f816618838a1d8fb0d66a25683e073e3a7a Mon Sep 17 00:00:00 2001 From: Qiang Huang Date: Mon, 16 May 2016 18:24:07 +0800 Subject: [PATCH] Add comments for error cases in status functions Signed-off-by: Qiang Huang --- libcontainer/container_linux.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libcontainer/container_linux.go b/libcontainer/container_linux.go index 6f12cbc88..a7527c150 100644 --- a/libcontainer/container_linux.go +++ b/libcontainer/container_linux.go @@ -1044,6 +1044,9 @@ func (c *linuxContainer) isRunning() (bool, error) { // return Running if the init process is alive if err := syscall.Kill(c.initProcess.pid(), 0); err != nil { if err == syscall.ESRCH { + // It means the process does not exist anymore, could happen when the + // process exited just when we call the function, we should not return + // error in this case. return false, nil } return false, newSystemErrorWithCausef(err, "sending signal 0 to pid %d", c.initProcess.pid()) @@ -1054,6 +1057,7 @@ func (c *linuxContainer) isRunning() (bool, error) { func (c *linuxContainer) isPaused() (bool, error) { data, err := ioutil.ReadFile(filepath.Join(c.cgroupManager.GetPaths()["freezer"], "freezer.state")) if err != nil { + // If freezer cgroup is not mounted, the container would just be not paused. if os.IsNotExist(err) { return false, nil }