Skip to content

Commit

Permalink
Wait for criuProcess once
Browse files Browse the repository at this point in the history
Signed-off-by: Ted Yu <yuzhihong@gmail.com>
  • Loading branch information
tedyu committed May 19, 2020
1 parent b207d57 commit 050fd19
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions libcontainer/container_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -1504,11 +1504,14 @@ func (c *linuxContainer) criuSwrk(process *Process, req *criurpc.CriuReq, opts *
// cmd.Process will be replaced by a restored init.
criuProcess := cmd.Process

var st *os.ProcessState
defer func() {
criuClientCon.Close()
_, err := criuProcess.Wait()
if err != nil {
return
if st == nil {
criuClientCon.Close()
_, err := criuProcess.Wait()
if err != nil {
return
}
}
}()

Expand Down Expand Up @@ -1634,7 +1637,7 @@ func (c *linuxContainer) criuSwrk(process *Process, req *criurpc.CriuReq, opts *
criuClientCon.CloseWrite()
// cmd.Wait() waits cmd.goroutines which are used for proxying file descriptors.
// Here we want to wait only the CRIU process.
st, err := criuProcess.Wait()
st, err = criuProcess.Wait()
if err != nil {
return err
}
Expand Down

0 comments on commit 050fd19

Please sign in to comment.