@@ -104,9 +104,9 @@ type Client struct {
104104 // goroutines.
105105 clientWaitGroup sync.WaitGroup
106106
107- // stderrWaitGroup is used to prevent the command's Wait() function from
108- // being called before we've finished reading from the stderr pipe.
109- stderrWaitGroup sync.WaitGroup
107+ // pipesWaitGroup is used to prevent the command's Wait() function from
108+ // being called before we've finished reading from the stdout and stderr pipe.
109+ pipesWaitGroup sync.WaitGroup
110110
111111 // processKilled is used for testing only, to flag when the process was
112112 // forcefully killed.
@@ -756,8 +756,8 @@ func (c *Client) Start() (addr net.Addr, err error) {
756756
757757 // Start goroutine that logs the stderr
758758 c .clientWaitGroup .Add (1 )
759- c .stderrWaitGroup .Add (1 )
760- // logStderr calls Done()
759+ c .pipesWaitGroup .Add (1 )
760+ // logStderr calls c.pipesWaitGroup. Done()
761761 go c .logStderr (runner .Name (), runner .Stderr ())
762762
763763 c .clientWaitGroup .Add (1 )
@@ -767,9 +767,9 @@ func (c *Client) Start() (addr net.Addr, err error) {
767767
768768 defer c .clientWaitGroup .Done ()
769769
770- // wait to finish reading from stderr since the stderr pipe reader
770+ // wait to finish reading from stdout/ stderr since the stdout/ stderr pipe readers
771771 // will be closed by the subsequent call to cmd.Wait().
772- c .stderrWaitGroup .Wait ()
772+ c .pipesWaitGroup .Wait ()
773773
774774 // Wait for the command to end.
775775 err := runner .Wait (context .Background ())
@@ -792,8 +792,10 @@ func (c *Client) Start() (addr net.Addr, err error) {
792792 // out of stdout
793793 linesCh := make (chan string )
794794 c .clientWaitGroup .Add (1 )
795+ c .pipesWaitGroup .Add (1 )
795796 go func () {
796797 defer c .clientWaitGroup .Done ()
798+ defer c .pipesWaitGroup .Done ()
797799 defer close (linesCh )
798800
799801 scanner := bufio .NewScanner (runner .Stdout ())
@@ -1159,7 +1161,7 @@ func (c *Client) getGRPCMuxer(addr net.Addr) (*grpcmux.GRPCClientMuxer, error) {
11591161
11601162func (c * Client ) logStderr (name string , r io.Reader ) {
11611163 defer c .clientWaitGroup .Done ()
1162- defer c .stderrWaitGroup .Done ()
1164+ defer c .pipesWaitGroup .Done ()
11631165 l := c .logger .Named (filepath .Base (name ))
11641166
11651167 reader := bufio .NewReaderSize (r , c .config .PluginLogBufferSize )
0 commit comments