diff options
author | gVisor bot <gvisor-bot@google.com> | 2021-07-22 22:44:35 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-07-22 22:44:35 +0000 |
commit | 967be575f24955d64e7a8b8e5b83ca23f0a5f0e1 (patch) | |
tree | f55ea982ce4537970e0278173c749b653d6c6ad7 /runsc/sandbox | |
parent | dd671896aeac26b154c98034e764119d47436ccd (diff) | |
parent | 47f025461e6fdf8da99c780b17c2227696e83845 (diff) |
Merge release-20210712.0-51-g47f025461 (automated)
Diffstat (limited to 'runsc/sandbox')
-rw-r--r-- | runsc/sandbox/sandbox.go | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/runsc/sandbox/sandbox.go b/runsc/sandbox/sandbox.go index 48efbb0b8..5fb7dc834 100644 --- a/runsc/sandbox/sandbox.go +++ b/runsc/sandbox/sandbox.go @@ -1157,27 +1157,26 @@ func (s *Sandbox) destroyContainer(cid string) error { } func (s *Sandbox) waitForStopped() error { + if s.child { + s.statusMu.Lock() + defer s.statusMu.Unlock() + if s.Pid == 0 { + return nil + } + // The sandbox process is a child of the current process, + // so we can wait it and collect its zombie. + if _, err := unix.Wait4(int(s.Pid), &s.status, 0, nil); err != nil { + return fmt.Errorf("error waiting the sandbox process: %v", err) + } + s.Pid = 0 + return nil + } + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() b := backoff.WithContext(backoff.NewConstantBackOff(100*time.Millisecond), ctx) op := func() error { - if s.child { - s.statusMu.Lock() - defer s.statusMu.Unlock() - if s.Pid == 0 { - return nil - } - // The sandbox process is a child of the current process, - // so we can wait it and collect its zombie. - wpid, err := unix.Wait4(int(s.Pid), &s.status, unix.WNOHANG, nil) - if err != nil { - return fmt.Errorf("error waiting the sandbox process: %v", err) - } - if wpid == 0 { - return fmt.Errorf("sandbox is still running") - } - s.Pid = 0 - } else if s.IsRunning() { + if s.IsRunning() { return fmt.Errorf("sandbox is still running") } return nil |