Replace tskill with taskkill

This offers a more reliable way of killing a process. The /IM flag
allows us to specify the "image name" of the process we're killing.
This means we can use wildcards, foce kill a process and all the child
processes it may have spawned.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
Gabriel Adrian Samfira 2021-12-20 18:33:36 +02:00
parent fd07b03689
commit 0ff87a8929
No known key found for this signature in database
GPG Key ID: 7D073DCC2C074CB5

View File

@ -364,7 +364,7 @@ func Randomize(str string) string {
func KillProcess(name string) error {
var command []string
if goruntime.GOOS == "windows" {
command = []string{"tskill", strings.TrimSuffix(name, ".exe")}
command = []string{"taskkill", "/IM", name, "/F"}
} else {
command = []string{"pkill", "-x", fmt.Sprintf("^%s$", name)}
}