From 22c50933290a4d098f97b5543e598a5d6e2df2a8 Mon Sep 17 00:00:00 2001 From: Wang Xu Date: Wed, 5 Apr 2017 18:31:15 +0800 Subject: [PATCH] reset container tty after container stopped so that we can reconnect it when container restarted. (hyperhq/hyperd#539) Signed-off-by: Wang Xu --- hypervisor/context.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hypervisor/context.go b/hypervisor/context.go index 017c1d16..7f53af71 100644 --- a/hypervisor/context.go +++ b/hypervisor/context.go @@ -244,6 +244,15 @@ func (ctx *VmContext) handleProcessAsyncEvent(pae *hyperstartapi.ProcessAsyncEve ctx.reportProcessFinished(types.E_CONTAINER_FINISHED, &types.ProcessFinished{ Id: pae.Container, Code: uint8(pae.Status), Ack: make(chan bool, 1), }) + ctx.lock.Lock() + if c, ok := ctx.containers[pae.Container]; ok { + c.Log(TRACE, "container finished, unset iostream pipes") + c.stdinPipe = nil + c.stdoutPipe = nil + c.stderrPipe = nil + c.tty = nil + } + ctx.lock.Unlock() } else { ctx.DeleteExec(pae.Process) ctx.reportProcessFinished(types.E_EXEC_FINISHED, &types.ProcessFinished{