> I tried to stop a waiting process in a goroutine by this on Windows.
> But it ends up killing the program immediately. What's your
> suggestion? Thanks.
Your program exited when your main goroutine executed
proc.Kill()
Causing this code in your worker goroutine to run
if err := cmd.Wait(); err != nil {
log.Fatal(err)
}
There is a race between log.Fatal() and your final log.Println(). When
you kill a subprocess, it will always exit with a non zero exit code
if it has not already completed.
Cheers
Dave