mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-20 11:48:24 -06:00
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:
parent
a4687c5b36
commit
e0325d9b8f
@ -59,6 +59,8 @@ func applyFn(ctx context.Context) error {
|
|||||||
|
|
||||||
// Setup the command
|
// Setup the command
|
||||||
cmd := exec.Command(shell, flag, command)
|
cmd := exec.Command(shell, flag, command)
|
||||||
|
// TODO: use exec.CommandContext when cancelation is fixed in Go
|
||||||
|
|
||||||
output, _ := circbuf.NewBuffer(maxBufSize)
|
output, _ := circbuf.NewBuffer(maxBufSize)
|
||||||
cmd.Stderr = io.MultiWriter(output, pw)
|
cmd.Stderr = io.MultiWriter(output, pw)
|
||||||
cmd.Stdout = io.MultiWriter(output, pw)
|
cmd.Stdout = io.MultiWriter(output, pw)
|
||||||
@ -82,7 +84,7 @@ func applyFn(ctx context.Context) error {
|
|||||||
case err = <-doneCh:
|
case err = <-doneCh:
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
cmd.Process.Kill()
|
cmd.Process.Kill()
|
||||||
err = cmd.Wait()
|
err = <-doneCh
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user