Skip to content

Commit 32b2eb7

Browse files
committed
hfexec: Pdeathsig is only supported in linux
1 parent b68d708 commit 32b2eb7

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

tfexec/cmd_sys_proc_attr_default.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//go:build !linux
2+
// +build !linux
3+
4+
package tfexec
5+
6+
import "syscall"
7+
8+
var defaultSysProcAttr = &syscall.SysProcAttr{
9+
// set process group ID
10+
Setpgid: true,
11+
}

tfexec/cmd_sys_proc_attr_linux.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//go:build linux
2+
// +build linux
3+
4+
package tfexec
5+
6+
import "syscall"
7+
8+
var defaultSysProcAttr = &syscall.SysProcAttr{
9+
// kill children if parent is dead
10+
Pdeathsig: syscall.SIGKILL,
11+
// set process group ID
12+
Setpgid: true,
13+
}

tfexec/cmd_unix.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,12 @@ import (
1010
"os/exec"
1111
"strings"
1212
"sync"
13-
"syscall"
1413
)
1514

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

19-
cmd.SysProcAttr = &syscall.SysProcAttr{
20-
// kill children if parent is dead
21-
Pdeathsig: syscall.SIGKILL,
22-
// set process group ID
23-
Setpgid: true,
24-
}
18+
cmd.SysProcAttr = defaultSysProcAttr
2519

2620
// check for early cancellation
2721
select {

0 commit comments

Comments
 (0)