Skip to content

Commit 350ad55

Browse files
committed
fix: Race condition on execution when context closes
Accessing ProcessState on non-linux operating systems immediately after context cancels can conflict with the Wait() stdlib func: https://github.com/golang/go/blob/36b81acfa19d9fedf6a0cd60c394fd7a7703834e/src/os/exec/exec.go#L511
1 parent 45fdb69 commit 350ad55

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tfexec/cmd_default.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func (tf *Terraform) runTerraformCmd(ctx context.Context, cmd *exec.Cmd) error {
1717
go func() {
1818
<-ctx.Done()
1919
if ctx.Err() == context.DeadlineExceeded || ctx.Err() == context.Canceled {
20-
if cmd != nil && cmd.Process != nil && cmd.ProcessState != nil {
20+
if cmd != nil && cmd.Process != nil {
2121
err := cmd.Process.Kill()
2222
if err != nil {
2323
tf.logger.Printf("error from kill: %s", err)

0 commit comments

Comments
 (0)