From 4bc94ce916cf0b20f7bb1725c4ad195a09a4cc0a Mon Sep 17 00:00:00 2001 From: TorchedSammy <38820196+TorchedSammy@users.noreply.github.com> Date: Sat, 21 May 2022 06:03:53 -0400 Subject: [PATCH] fix: set bg proc attr in build tagged file --- exec.go | 12 ------------ execfile_unix.go | 5 +++++ execfile_windows.go | 5 +++++ job.go | 1 + 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/exec.go b/exec.go index 83fcb15..2e0e0b1 100644 --- a/exec.go +++ b/exec.go @@ -359,18 +359,6 @@ func execHandle(bg bool) interp.ExecHandlerFunc { var j *job if bg { - var procAttr *syscall.SysProcAttr - if runtime.GOOS == "windows" { - procAttr = &syscall.SysProcAttr{ - CreationFlags: syscall.CREATE_NEW_PROCESS_GROUP, - } - } else { - procAttr = &syscall.SysProcAttr{ - Setpgid: true, - } - } - cmd.SysProcAttr = procAttr - j = jobs.getLatest() j.setHandle(&cmd) err = j.start() diff --git a/execfile_unix.go b/execfile_unix.go index 3160b85..44f924a 100644 --- a/execfile_unix.go +++ b/execfile_unix.go @@ -4,8 +4,13 @@ package main import ( "os" + "syscall" ) +var bgProcAttr *syscall.SysProcAttr = &syscall.SysProcAttr{ + Setpgid: true, +} + func findExecutable(path string, inPath, dirs bool) error { f, err := os.Stat(path) if err != nil { diff --git a/execfile_windows.go b/execfile_windows.go index 502a595..4b3feef 100644 --- a/execfile_windows.go +++ b/execfile_windows.go @@ -5,8 +5,13 @@ package main import ( "path/filepath" "os" + "syscall" ) +var bgProcAttr *syscall.SysProcAttr = &syscall.SysProcAttr{ + CreationFlags: syscall.CREATE_NEW_PROCESS_GROUP, +} + func findExecutable(path string, inPath, dirs bool) error { nameExt := filepath.Ext(path) pathExts := filepath.SplitList(os.Getenv("PATHEXT")) diff --git a/job.go b/job.go index 13dfb8e..b706c72 100644 --- a/job.go +++ b/job.go @@ -43,6 +43,7 @@ func (j *job) start() error { } j.setHandle(&cmd) } + j.handle.SysProcAttr = bgProcAttr if !j.once { j.once = true