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()