From 1fb786a126d72ca586264f4629e86cff47b1a30d Mon Sep 17 00:00:00 2001 From: "milton.sun" Date: Sun, 21 Jul 2019 22:56:42 +0800 Subject: [PATCH] multiproc apipe bug make the process block --- src/multiproc/apipe/apipe.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/multiproc/apipe/apipe.go b/src/multiproc/apipe/apipe.go index 1d1c102..8084881 100644 --- a/src/multiproc/apipe/apipe.go +++ b/src/multiproc/apipe/apipe.go @@ -33,13 +33,14 @@ func demo2() { fmt.Printf("Error: Can not obtain the stdin pipe for command: %s\n", err) return } - outputBuf1.WriteTo(stdin2) + var outputBuf2 bytes.Buffer cmd2.Stdout = &outputBuf2 if err := cmd2.Start(); err != nil { fmt.Printf("Error: The command can not be startup: %s\n", err) return } + outputBuf1.WriteTo(stdin2) err = stdin2.Close() if err != nil { fmt.Printf("Error: Can not close the stdio pipe: %s\n", err)