Skip to content

Commit d56bb5a

Browse files
committed
Remove runTerraformCmd check for cmd.ProcessState
Processes were not being killed because cmd.ProcessState was nil. With this change, processes will be able to make the request to Kill(). Note: this will cause hanging `TestContext_sleepTimeoutExpired` due to a known Golang issue with killing a command when Stdout or Stderr are set to anything besides `nil` or `*os.File`. This is because the Kill does not notify the stdout/stderr subprocesses to stop. `cmd.Wait` (called by `cmd.Run`) waits indefinitely for those subprocesses to stop.
1 parent 400f9d7 commit d56bb5a

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
@@ -18,7 +18,7 @@ func (tf *Terraform) runTerraformCmd(ctx context.Context, cmd *exec.Cmd) error {
1818
go func() {
1919
<-ctx.Done()
2020
if ctx.Err() == context.DeadlineExceeded || ctx.Err() == context.Canceled {
21-
if cmd != nil && cmd.Process != nil && cmd.ProcessState != nil {
21+
if cmd != nil && cmd.Process != nil {
2222
err := cmd.Process.Kill()
2323
if err != nil {
2424
tf.logger.Printf("error from kill: %s", err)

0 commit comments

Comments
 (0)