How do you keep a process running after main exit?
Update: It turns out it is only when you are running in goland. The accepted answer including comments solved this.
Info: I have an executable that watches a folder for changes, and I need to start it from go and keep it running after exit.
I have see this but it does not solve the problem of running the process after exit.
package main
import "os/exec"
func main() {
cmd := exec.Command("sh", "long_running process", "&")
cmd.Start()
}
fmt.Println("Sleeping...")
time.Sleep(8 * time.Second) // I can see the process running
Afterwards when I do "ps" the process is killed with the main application.