I'm trying to figure out how to run an executable file from Go using ForkExec. Having tried this so far:
var sysProcAttr = syscall.SysProcAttr{}
sysProcAttr.Setsid = true
sysProcAttr.Foreground = false
var procAttr = syscall.ProcAttr{
Dir: "/",
Env: nil,
Sys: &sysProcAttr,
}
processID, err = syscall.ForkExec("/home/ubuntu/.dotnet/dotnet", []string{"/home/ubuntu/my-executable-net-dll-file"}, &procAttr)
return processID, err
This creates a process, but when I close the Go application these processes close as well. The question is - how do I detach the process from it? It appears that Setsid doesn't work, the only options left are to use nohup or "bash -c", but I fear the results will be the same.