On Windows, The *Setsid* does not exist, so I use the Windows Job Object to perform this. Here is my demostration <https://github.com/hayden-pan/archiver/blob/ca5329ba8be137a69b8441ec2980227bf75486b2/7z_windows.go>, hope to help others.
On Thursday, July 6, 2023 at 3:12:33 PM UTC+8 Peter Galbavy wrote: > Yes, setsid combined with cmd.Process.Release() works for me. > > My local / specific needs code is > https://github.com/ITRS-Group/cordial/blob/ad18bfbfa44eff1b9b66408394dd83749da25bb1/pkg/process/process.go#L64 > > which works well for everything I have thrown at it (on Linux). > > On Wednesday, 5 July 2023 at 16:23:16 UTC+1 Brian Candler wrote: > >> > Is there any way to create a child process that is detached from the >> original cgroup using exec.Command? >> > I don't want my child process to be killed when the parent process >> dies. >> >> This might be an issue with process groups, not cgroups, in which case I >> think Setsid is what you want, something like (untested): >> >> p.theCommand.SysProcAttr = &syscall.SysProcAttr{Setsid: true} >> err := p.theCommand.Start() >> >> I had a related problem: I wanted to make sure that when a timeout >> occurs, I forcibly kill the child process and all its descendants. Solution >> was to use Setsid, and then send the signal to the newly-formed process >> group: >> https://groups.google.com/g/golang-nuts/c/V1VccYYCp9o/m/rZRfhP_bCAAJ >> >> -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/4c177671-98ad-4dcc-8e12-a2e315c3dbabn%40googlegroups.com.