GODT-2111: Give the child process its own group ID

This commit is contained in:
Romain LE JEUNE
2022-11-20 11:01:33 +01:00
parent 054d9b3f09
commit 81facfd05f
2 changed files with 17 additions and 2 deletions

View File

@ -20,8 +20,16 @@
package restarter
import "os/exec"
import (
"os/exec"
"syscall"
)
func run(cmd *exec.Cmd) error {
// Provide a new Group ID to the new process to ensure the child is detached even if parent crash before ending.
cmd.SysProcAttr = &syscall.SysProcAttr{
Setpgid: true,
Pgid: 0,
}
return cmd.Start()
}

View File

@ -20,8 +20,15 @@
package restarter
import "os/exec"
import (
"os/exec"
"syscall"
)
func run(cmd *exec.Cmd) error {
// Provide a new Group ID to the new process to ensure the child is detached even if parent crash before ending.
cmd.SysProcAttr = &syscall.SysProcAttr{
CreationFlags: syscall.CREATE_NEW_PROCESS_GROUP,
}
return cmd.Run()
}