MCPcopy
hub / github.com/opencontainers/runc / refreshState

Method refreshState

libcontainer/container_linux.go:874–891  ·  view source on GitHub ↗

refreshState needs to be called to verify that the current state on the container is what is true. Because consumers of libcontainer can use it out of process we need to verify the container's status based on runtime information and not rely on our in process info.

()

Source from the content-addressed store, hash-verified

872// out of process we need to verify the container's status based on runtime
873// information and not rely on our in process info.
874func (c *Container) refreshState() error {
875 paused, err := c.isPaused()
876 if err != nil {
877 return err
878 }
879 if paused {
880 return c.state.transition(&pausedState{c: c})
881 }
882 if !c.hasInit() {
883 return c.state.transition(&stoppedState{c: c})
884 }
885 // The presence of exec fifo helps to distinguish between
886 // the created and the running states.
887 if _, err := os.Stat(filepath.Join(c.stateDir, execFifoFilename)); err == nil {
888 return c.state.transition(&createdState{c: c})
889 }
890 return c.state.transition(&runningState{c: c})
891}
892
893// hasInit tells whether the container init process exists.
894func (c *Container) hasInit() bool {

Callers 3

LoadFunction · 0.95
currentStatusMethod · 0.95
destroyMethod · 0.80

Calls 3

isPausedMethod · 0.95
hasInitMethod · 0.95
transitionMethod · 0.65

Tested by

no test coverage detected