Fix potential containerd panic.

Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
Lantao Liu 2019-02-05 00:38:02 -08:00
parent ca65dc9316
commit 7bd8dcd0d3
2 changed files with 9 additions and 5 deletions

View File

@ -111,9 +111,11 @@ func (p *process) Start(ctx context.Context) error {
ExecID: p.id, ExecID: p.id,
}) })
if err != nil { if err != nil {
p.io.Cancel() if p.io != nil {
p.io.Wait() p.io.Cancel()
p.io.Close() p.io.Wait()
p.io.Close()
}
return errdefs.FromGRPC(err) return errdefs.FromGRPC(err)
} }
p.pid = r.Pid p.pid = r.Pid

View File

@ -189,8 +189,10 @@ func (t *task) Start(ctx context.Context) error {
ContainerID: t.id, ContainerID: t.id,
}) })
if err != nil { if err != nil {
t.io.Cancel() if t.io != nil {
t.io.Close() t.io.Cancel()
t.io.Close()
}
return errdefs.FromGRPC(err) return errdefs.FromGRPC(err)
} }
t.pid = r.Pid t.pid = r.Pid