From bf4838eb716284a57ae7d9a76eb1176a9e2c34cd Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Wed, 2 Aug 2017 15:02:52 -0400 Subject: [PATCH] Shutdown console after process exits Signed-off-by: Michael Crosby --- linux/shim/init.go | 4 +--- linux/task.go | 15 ++++++--------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/linux/shim/init.go b/linux/shim/init.go index 76657f2ed..66fb55152 100644 --- a/linux/shim/init.go +++ b/linux/shim/init.go @@ -229,6 +229,7 @@ func (p *initProcess) SetExited(status int) { p.mu.Lock() p.status = status p.exited = time.Now() + p.platform.shutdownConsole(context.Background(), p.console) p.mu.Unlock() } @@ -241,9 +242,6 @@ func (p *initProcess) Delete(context context.Context) error { return fmt.Errorf("cannot delete a running container") } p.killAll(context) - if err := p.platform.shutdownConsole(context, p.console); err != nil { - log.G(context).WithError(err).Warn("Failed to shutdown container console") - } p.Wait() err = p.runtime.Delete(context, p.id, nil) if p.io != nil { diff --git a/linux/task.go b/linux/task.go index ee7807240..306d6a0ed 100644 --- a/linux/task.go +++ b/linux/task.go @@ -86,23 +86,21 @@ func (t *Task) Pause(ctx context.Context) error { } func (t *Task) Resume(ctx context.Context) error { - _, err := t.shim.Resume(ctx, empty) - if err != nil { - err = errdefs.FromGRPC(err) + if _, err := t.shim.Resume(ctx, empty); err != nil { + return errdefs.FromGRPC(err) } - return err + return nil } func (t *Task) Kill(ctx context.Context, signal uint32, all bool) error { - _, err := t.shim.Kill(ctx, &shim.KillRequest{ + if _, err := t.shim.Kill(ctx, &shim.KillRequest{ ID: t.id, Signal: signal, All: all, - }) - if err != nil { + }); err != nil { return errdefs.FromGRPC(err) } - return err + return nil } func (t *Task) Exec(ctx context.Context, id string, opts runtime.ExecOpts) (runtime.Process, error) { @@ -125,7 +123,6 @@ func (t *Task) Exec(ctx context.Context, id string, opts runtime.ExecOpts) (runt func (t *Task) Pids(ctx context.Context) ([]uint32, error) { resp, err := t.shim.ListPids(ctx, &shim.ListPidsRequest{ - // TODO: (@crosbymichael) this id can probably be removed ID: t.id, }) if err != nil {