diff options
author | Andrei Vagin <avagin@gmail.com> | 2021-06-22 10:47:37 -0700 |
---|---|---|
committer | Andrei Vagin <avagin@gmail.com> | 2021-06-22 11:01:31 -0700 |
commit | d703340bc04a4269f420fdf24d946abcbc6a620b (patch) | |
tree | 1fbcb33795a009c56a16823611cf471d733c4aa5 /runsc/sandbox | |
parent | bc27a991851fdffa59f028eecfc22bdd17ccaa55 (diff) |
runsc: don't kill sandbox, let it stop properly
The typical sequence of calls to start a container looks like this
ct, err := container.New(conf, containerArgs)
defer ct.Destroy()
ct.Start(conf)
ws, err := ct.Wait()
For the root container, ct.Destroy() kills the sandbox process. This
doesn't look like a right wait to stop it. For example, all ongoing rpc
calls are aborted in this case. If everything is going alright, we can
just wait and it will exit itself.
Reported-by: syzbot+084fca334720887441e7@syzkaller.appspotmail.com
Signed-off-by: Andrei Vagin <avagin@gmail.com>
Diffstat (limited to 'runsc/sandbox')
-rw-r--r-- | runsc/sandbox/sandbox.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/runsc/sandbox/sandbox.go b/runsc/sandbox/sandbox.go index 29e202b7d..f14cc7229 100644 --- a/runsc/sandbox/sandbox.go +++ b/runsc/sandbox/sandbox.go @@ -797,7 +797,13 @@ func (s *Sandbox) Wait(cid string) (unix.WaitStatus, error) { // Try the Wait RPC to the sandbox. var ws unix.WaitStatus err = conn.Call(boot.ContainerWait, &cid, &ws) + conn.Close() if err == nil { + if s.IsRootContainer(cid) { + if err := s.waitForStopped(); err != nil { + return unix.WaitStatus(0), err + } + } // It worked! return ws, nil } |