diff --git a/container_linux.go b/container_linux.go index 4e04f793..5f8120b6 100644 --- a/container_linux.go +++ b/container_linux.go @@ -356,10 +356,21 @@ func (c *linuxContainer) Restore(process *Process) error { if err := cmd.Start(); err != nil { return err } + + // cmd.Wait() waits cmd.goroutines which are used for proxying file descriptors. + // Here we want to wait only the CRIU process. + st, err := cmd.Process.Wait() + if err != nil { + return err + } + if !st.Success() { + return fmt.Errorf("criu failed: %s", st.String()) + } r, err := newRestoredProcess(pidfile, cmd) if err != nil { return err } + // TODO: crosbymichael restore previous process information by saving the init process information in // the conatiner's state file or separate process state files. if err := c.updateState(r); err != nil { diff --git a/restored_process.go b/restored_process.go index d6b49387..1afcb44e 100644 --- a/restored_process.go +++ b/restored_process.go @@ -8,7 +8,6 @@ import ( "os" "os/exec" "strconv" - "time" "github.com/docker/libcontainer/system" ) @@ -18,21 +17,8 @@ func newRestoredProcess(pidfile string, criuCommand *exec.Cmd) (*restoredProcess data []byte err error ) - // XXX The loop below should be replaced by a wait - // on CRIU to complete. See the comment at the - // begining of Restore() in "container_linux.go. - for i := 0; i < 20; i++ { - data, err = ioutil.ReadFile(pidfile) - if err == nil { - break - } - if !os.IsNotExist(err) { - return nil, err - } - time.Sleep(100 * time.Millisecond) - } - // Did CRIU fail? - if os.IsNotExist(err) { + data, err = ioutil.ReadFile(pidfile) + if err != nil { return nil, err } if len(data) == 0 {