diff --git a/pkg/restarter/start_default.go b/pkg/restarter/start_default.go index cec99e76..47aca556 100644 --- a/pkg/restarter/start_default.go +++ b/pkg/restarter/start_default.go @@ -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() } diff --git a/pkg/restarter/start_windows.go b/pkg/restarter/start_windows.go index e9807e5c..05a3ac62 100644 --- a/pkg/restarter/start_windows.go +++ b/pkg/restarter/start_windows.go @@ -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() }