Skip to content

Commit

Permalink
hfexec: Pdeathsig is only supported in linux
Browse files Browse the repository at this point in the history
  • Loading branch information
simon0191 committed Sep 1, 2022
1 parent 44715fe commit 24313c4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
8 changes: 8 additions & 0 deletions tfexec/cmd_sys_proc_attr_default.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//go:build !linux
// +build !linux

package tfexec

import "syscall"

var defaultSysProcAttr = &syscall.SysProcAttr{}
13 changes: 13 additions & 0 deletions tfexec/cmd_sys_proc_attr_linux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//go:build linux
// +build linux

package tfexec

import "syscall"

var defaultSysProcAttr = &syscall.SysProcAttr{
// kill children if parent is dead
Pdeathsig: syscall.SIGKILL,
// set process group ID
Setpgid: true,
}
8 changes: 1 addition & 7 deletions tfexec/cmd_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,12 @@ import (
"os/exec"
"strings"
"sync"
"syscall"
)

func (tf *Terraform) runTerraformCmd(ctx context.Context, cmd *exec.Cmd) error {
var errBuf strings.Builder

cmd.SysProcAttr = &syscall.SysProcAttr{
// kill children if parent is dead
Pdeathsig: syscall.SIGKILL,
// set process group ID
Setpgid: true,
}
cmd.SysProcAttr = defaultSysProcAttr

// check for early cancellation
select {
Expand Down

0 comments on commit 24313c4

Please sign in to comment.