From 77b025a48d9dc89666ef7c03709ef1fc2a4d0b34 Mon Sep 17 00:00:00 2001
From: lujingxiao <lujingxiao@huawei.com>
Date: Wed, 23 Jan 2019 15:00:12 +0800
Subject: [PATCH 09/27] runtime:  fix pipe in broken may cause shim
 lock forever for runtime v2

reason: fix pipe in broken may cause shim lock forever for runtime v2

Cherry-pick from upstream b3438f7a6f

Change-Id: I3c324050531a1e68a5c3a688a51408a121a3f9f1
Signed-off-by: Lifubang <lifubang@acmcoder.com>
Signed-off-by: lujingxiao <lujingxiao@huawei.com>
---
 runtime/v2/runc/service_linux.go | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/runtime/v2/runc/service_linux.go b/runtime/v2/runc/service_linux.go
index 5e30cfc..19d1fec 100644
--- a/runtime/v2/runc/service_linux.go
+++ b/runtime/v2/runc/service_linux.go
@@ -49,9 +49,10 @@ func (p *linuxPlatform) CopyConsole(ctx context.Context, console console.Console
 		cwg.Add(1)
 		go func() {
 			cwg.Done()
-			p := bufPool.Get().(*[]byte)
-			defer bufPool.Put(p)
-			io.CopyBuffer(epollConsole, in, *p)
+			bp := bufPool.Get().(*[]byte)
+			defer bufPool.Put(bp)
+			io.CopyBuffer(epollConsole, in, *bp)
+			epollConsole.Shutdown(p.epoller.CloseConsole)
 		}()
 	}
 
-- 
2.7.4.3

