Start/Wait on exec.Cmd when using pipes
Created by: mrnugget
This might've been the cause for the flaky test we saw (example failure here).
The docs say that cmd.Run()
in combination with StdoutPipe
/StderrPipe
is wrong:
Wait
will close the pipe after seeing the command exit, so most callers need not close the pipe themselves. It is thus incorrect to callWait
before all reads from the pipe have completed. For the same reason, it is incorrect to callRun
when usingStdoutPipe
. See the example for idiomatic usage.