fix: use setpgid on cmd procattr for background jobs

extended-job-api
TorchedSammy 2022-05-20 09:19:07 -04:00
parent 055132aa10
commit 4a5e4957d7
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
1 changed files with 12 additions and 0 deletions

12
exec.go
View File

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