From 16b34edb97468064a1e37469fbdc0b4ba4b7d952 Mon Sep 17 00:00:00 2001 From: wenxian li Date: Sat, 23 Jun 2018 09:00:54 +0000 Subject: [PATCH] the closed threads are leaved as Zombie state --- gexpect.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gexpect.go b/gexpect.go index 6e918cb..3309627 100644 --- a/gexpect.go +++ b/gexpect.go @@ -150,6 +150,9 @@ func (expect *ExpectSubprocess) Close() error { if err := expect.Cmd.Process.Kill(); err != nil { return err } + if _, err := expect.Cmd.Process.Wait(); err != nil { + return err + } if err := expect.buf.f.Close(); err != nil { return err } @@ -387,7 +390,7 @@ func (expect *ExpectSubprocess) ReadUntil(delim byte) ([]byte, error) { for i := 0; i < n; i++ { if chunk[i] == delim { if len(chunk) > i+1 { - expect.buf.PutBack(chunk[i+1:n]) + expect.buf.PutBack(chunk[i+1 : n]) } return join, nil } else {