From a3ec97f9fa099d3094ab807973aa86ce9451b47a Mon Sep 17 00:00:00 2001 From: Chetan Sarva Date: Thu, 21 Jul 2022 09:47:55 -0400 Subject: [PATCH] fix: simpler process cleanup --- cmd.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/cmd.go b/cmd.go index 8c41df2..5116a00 100644 --- a/cmd.go +++ b/cmd.go @@ -5,7 +5,6 @@ import ( "log" "os" "os/exec" - "syscall" "github.com/shirou/gopsutil/process" ) @@ -32,15 +31,14 @@ func stopCommand(cmd *exec.Cmd) { fmt.Println("[*] stopping process", cmd.Process.Pid) proc, err := process.NewProcess(int32(cmd.Process.Pid)) if err != nil { - fmt.Println("error finding child process:", err) - err := cmd.Process.Signal(syscall.SIGTERM) - if err != nil { - fmt.Println("error killing child process:", err) + if err.Error() == "process does not exist" { + return } + fmt.Println("[*] warning: error finding child process:", err) } else { err = proc.Terminate() if err != nil { - fmt.Println("error killing child process:", err) + fmt.Println("[*] error killing child process:", err) } } cmd.Process.Wait()