Why won't Go kill a child process correctly?

后端 未结 5 551
小蘑菇
小蘑菇 2020-12-14 23:43

The following works just fine when cmd finishes in the allotted time. However, the timeout is not working. While it does print \"It\'s dead Jim\", not only do

5条回答
  •  长情又很酷
    2020-12-15 00:16

    Just for reference, I'll put my Windows solution here as well:

    func kill(cmd *exec.Cmd) error {
        kill := exec.Command("TASKKILL", "/T", "/F", "/PID", strconv.Itoa(cmd.Process.Pid))
        kill.Stderr = os.Stderr
        kill.Stdout = os.Stdout
        return kill.Run()
     }
    

提交回复
热议问题