provisioners/local-exec: remove data race by setting err only once
This commit is contained in:
parent
3e771a674c
commit
3776d31d69
|
@ -72,15 +72,14 @@ func applyFn(ctx context.Context) error {
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// Wait for the command to complete in a goroutine
|
// Wait for the command to complete in a goroutine
|
||||||
doneCh := make(chan struct{})
|
doneCh := make(chan error, 1)
|
||||||
go func() {
|
go func() {
|
||||||
defer close(doneCh)
|
doneCh <- cmd.Wait()
|
||||||
err = cmd.Wait()
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Wait for the command to finish or for us to be interrupted
|
// Wait for the command to finish or for us to be interrupted
|
||||||
select {
|
select {
|
||||||
case <-doneCh:
|
case err = <-doneCh:
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
cmd.Process.Kill()
|
cmd.Process.Kill()
|
||||||
err = cmd.Wait()
|
err = cmd.Wait()
|
||||||
|
|
Loading…
Reference in New Issue