Skip to content

Commit 11defa8

Browse files
committed
Fix OS compatibility issues
1 parent 982574f commit 11defa8

File tree

4 files changed

+37
-2
lines changed

4 files changed

+37
-2
lines changed

application/command/hook_exec.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"os"
88
"os/exec"
99
"strings"
10-
"syscall"
1110
)
1211

1312
// Predefined prefixes
@@ -114,7 +113,7 @@ func (e ExecHook) Run(
114113

115114
cmd, args := e[0], e[1:]
116115
exec := exec.CommandContext(ctx, cmd, args...)
117-
exec.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
116+
configureExecCommand(exec)
118117
exec.Stdout = HookOutputWriter(output.Out)
119118
exec.Stderr = HookOutputWriter(output.Err)
120119
exec.Env = e.mergeParametersWithEnvirons(params, defaultHookEnvirons)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//go:build !(darwin || dragonfly || freebsd || linux || netbsd || openbsd || windows)
2+
3+
package command
4+
5+
import "os/exec"
6+
7+
// configureExecCommand configures given `e`
8+
func configureExecCommand(e *exec.Cmd) {
9+
// By default, do nothing
10+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd
2+
3+
package command
4+
5+
import (
6+
"os/exec"
7+
"syscall"
8+
)
9+
10+
// configureExecCommand configures given `e` for Unix-like systems
11+
func configureExecCommand(e *exec.Cmd) {
12+
e.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//go:build windows
2+
3+
package command
4+
5+
import (
6+
"os/exec"
7+
"syscall"
8+
)
9+
10+
// configureExecCommand configures given `e` for Windows
11+
func configureExecCommand(e *exec.Cmd) {
12+
e.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
13+
}

0 commit comments

Comments
 (0)