From 89af1089d50add85872a6a7443e292669b6d7cc1 Mon Sep 17 00:00:00 2001 From: Dingjun Date: Mon, 7 Aug 2017 11:16:03 +0800 Subject: [PATCH] handle panic --- util.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/util.go b/util.go index 65f47f5..7ef4892 100644 --- a/util.go +++ b/util.go @@ -20,6 +20,11 @@ var SSHLogLevel = ERROR // PipeAndClose pipe the data between c and s, close both when done func PipeAndClose(c io.ReadWriteCloser, s io.ReadWriteCloser) { + defer func() { + if err := recover(); err != nil { + log.Printf("recovered: %+v", err) + } + }() defer c.Close() defer s.Close() cc := make(chan struct{}, 2)