Skip to content

Commit c8b4e4d

Browse files
Merge pull request containerd#1277 from crosbymichael/tty-block
Shutdown console after process exits
2 parents ee2dea2 + bf4838e commit c8b4e4d

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

linux/shim/init.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ func (p *initProcess) SetExited(status int) {
229229
p.mu.Lock()
230230
p.status = status
231231
p.exited = time.Now()
232+
p.platform.shutdownConsole(context.Background(), p.console)
232233
p.mu.Unlock()
233234
}
234235

@@ -241,9 +242,6 @@ func (p *initProcess) Delete(context context.Context) error {
241242
return fmt.Errorf("cannot delete a running container")
242243
}
243244
p.killAll(context)
244-
if err := p.platform.shutdownConsole(context, p.console); err != nil {
245-
log.G(context).WithError(err).Warn("Failed to shutdown container console")
246-
}
247245
p.Wait()
248246
err = p.runtime.Delete(context, p.id, nil)
249247
if p.io != nil {

linux/task.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,23 +86,21 @@ func (t *Task) Pause(ctx context.Context) error {
8686
}
8787

8888
func (t *Task) Resume(ctx context.Context) error {
89-
_, err := t.shim.Resume(ctx, empty)
90-
if err != nil {
91-
err = errdefs.FromGRPC(err)
89+
if _, err := t.shim.Resume(ctx, empty); err != nil {
90+
return errdefs.FromGRPC(err)
9291
}
93-
return err
92+
return nil
9493
}
9594

9695
func (t *Task) Kill(ctx context.Context, signal uint32, all bool) error {
97-
_, err := t.shim.Kill(ctx, &shim.KillRequest{
96+
if _, err := t.shim.Kill(ctx, &shim.KillRequest{
9897
ID: t.id,
9998
Signal: signal,
10099
All: all,
101-
})
102-
if err != nil {
100+
}); err != nil {
103101
return errdefs.FromGRPC(err)
104102
}
105-
return err
103+
return nil
106104
}
107105

108106
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
125123

126124
func (t *Task) Pids(ctx context.Context) ([]uint32, error) {
127125
resp, err := t.shim.ListPids(ctx, &shim.ListPidsRequest{
128-
// TODO: (@crosbymichael) this id can probably be removed
129126
ID: t.id,
130127
})
131128
if err != nil {

0 commit comments

Comments
 (0)