Not a direct answer to your question, but I've come across plenty of issues 
that prevented reliable termination of external processes (along with their 
children). Eventually I came to this solution, it's been thoroughly tested 
in production:

func KillProcess(proc *os.Process)
https://github.com/HouzuoGuo/laitos/blob/master/platform/sys_unix.go#L111

And similar for Windows:

func KillProcess(proc *os.Process)
https://github.com/HouzuoGuo/laitos/blob/master/platform/sys_windows.go#L100


On Friday, 10 July 2020 02:14:33 UTC+3, Ian Gudger wrote:
>
> I am using Go 1.14 AMD64 on Linux 5.3.0.
>
> When I create a subprocess with exec.Cmd.Start, I can't seem to fully kill 
> it with exec.Cmd.Process.Kill, or at least not to the satisfaction 
> of exec.Cmd.Wait.
>
> I am doing something along the lines of:
> cmd := exec.Command(binPath)
> if err := cmd.Start(); err != nil {
> ...
> }
> if err := cmd.Process.Kill(); err != nil {
> ...
> }
> if err := cmd.Wait(); err != nil {
> ...
> }
>
> However, this hangs on Wait. As far as I can tell this shouldn't happen. 
> Any idea what I might be doing wrong?
>

-- 
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 on the web visit 
https://groups.google.com/d/msgid/golang-nuts/055ca8a3-a286-4d3e-bdc4-964a1bd39936o%40googlegroups.com.

Reply via email to