fix race with multiple calls to cmd.Wait()

There was still a race around the local-exec Command, where we were
calling Wait in 2 places which you can't do.
This commit is contained in:
James Bardin 2017-01-31 18:07:26 -05:00
parent a4687c5b36
commit e0325d9b8f

View File

@ -59,6 +59,8 @@ func applyFn(ctx context.Context) error {
// Setup the command
cmd := exec.Command(shell, flag, command)
// TODO: use exec.CommandContext when cancelation is fixed in Go
output, _ := circbuf.NewBuffer(maxBufSize)
cmd.Stderr = io.MultiWriter(output, pw)
cmd.Stdout = io.MultiWriter(output, pw)
@ -82,7 +84,7 @@ func applyFn(ctx context.Context) error {
case err = <-doneCh:
case <-ctx.Done():
cmd.Process.Kill()
err = cmd.Wait()
err = <-doneCh
}
}