From 63328251fac0b49d1c340388ea9982529604107d Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Wed, 3 Jul 2019 03:04:28 -0600 Subject: [PATCH] win: add missing hidewindow syscall --- runner/runner.go | 1 + runner/runner_notwindows.go | 8 ++++++++ runner/runner_windows.go | 10 ++++------ 3 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 runner/runner_notwindows.go diff --git a/runner/runner.go b/runner/runner.go index 600db19..8c80e6b 100644 --- a/runner/runner.go +++ b/runner/runner.go @@ -52,6 +52,7 @@ func Run(conf *service.Service) { start := time.Now() cmd := exec.Command(binpath, args...) + backgroundCmd(cmd) fmt.Fprintf(lf, "[%s] Starting %q %s \n", time.Now(), binpath, strings.Join(args, " ")) cmd.Stdin = nil diff --git a/runner/runner_notwindows.go b/runner/runner_notwindows.go new file mode 100644 index 0000000..71b636c --- /dev/null +++ b/runner/runner_notwindows.go @@ -0,0 +1,8 @@ +// +build !windows + +package runner + +import "os/exec" + +func backgroundCmd(cmd *exec.Cmd) { +} diff --git a/runner/runner_windows.go b/runner/runner_windows.go index bd5b0bc..df358f4 100644 --- a/runner/runner_windows.go +++ b/runner/runner_windows.go @@ -2,11 +2,9 @@ package runner import ( "os/exec" + "syscall" ) -func init() { - cmd, _ := exec.LookPath("cmd.exe") - if "" != cmd { - shellArgs = []string{cmd, "/c"} - } -} \ No newline at end of file +func backgroundCmd(cmd *exec.Cmd) { + cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true} +}