Skip to content

Commit a3ec97f

Browse files
committed
fix: simpler process cleanup
1 parent 7bda280 commit a3ec97f

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

cmd.go

+4-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"log"
66
"os"
77
"os/exec"
8-
"syscall"
98

109
"github.com/shirou/gopsutil/process"
1110
)
@@ -32,15 +31,14 @@ func stopCommand(cmd *exec.Cmd) {
3231
fmt.Println("[*] stopping process", cmd.Process.Pid)
3332
proc, err := process.NewProcess(int32(cmd.Process.Pid))
3433
if err != nil {
35-
fmt.Println("error finding child process:", err)
36-
err := cmd.Process.Signal(syscall.SIGTERM)
37-
if err != nil {
38-
fmt.Println("error killing child process:", err)
34+
if err.Error() == "process does not exist" {
35+
return
3936
}
37+
fmt.Println("[*] warning: error finding child process:", err)
4038
} else {
4139
err = proc.Terminate()
4240
if err != nil {
43-
fmt.Println("error killing child process:", err)
41+
fmt.Println("[*] error killing child process:", err)
4442
}
4543
}
4644
cmd.Process.Wait()

0 commit comments

Comments
 (0)