From 4a5e4957d79b69c18df9c91a66302d41fdbb7267 Mon Sep 17 00:00:00 2001 From: TorchedSammy <38820196+TorchedSammy@users.noreply.github.com> Date: Fri, 20 May 2022 09:19:07 -0400 Subject: [PATCH] fix: use setpgid on cmd procattr for background jobs --- exec.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/exec.go b/exec.go index 2e0e0b1..ddd556d 100644 --- a/exec.go +++ b/exec.go @@ -359,6 +359,18 @@ 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()