相关疑难解决方法(0)

杀死子进程 - exec.Command

你如何杀死子进程?

我有一个长时间运行的应用程序,使用“exec.Command”启动一个新进程:

// ...I am a long running application in the background

// Now I am starting a child process, that should be killed togeter with the parent application.
cmd := exec.Command("sh", "-c", execThis)

// create a new process group
// cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
Run Code Online (Sandbox Code Playgroud)

现在,如果我杀死<pid of long running application in the background>它不会杀死子进程 - 你知道怎么做吗?

go

0
推荐指数
1
解决办法
70
查看次数

标签 统计

go ×1