ACN Process Management #345

Merged
dan merged 14 commits from torrc into master 2020-10-21 23:58:59 +00:00
1 changed files with 4 additions and 2 deletions
Showing only changes of commit 5f5ea56989 - Show all commits

View File

@ -12,8 +12,8 @@ import (
// process matches the expected name, then it is killed.
// On windows this uses tasklist...
func CheckProcessAndKill(pid uint64, processName string) {
log.Debugf("killing: %v", pid)
bytes,err := exec.Command("tasklist", "/fi", "\"pid eq "+strconv.Itoa(int(pid))+"\"").Output()
log.Debugf("looking up process: %v", pid)
bytes,err := exec.Command("tasklist", "/fi", "pid eq "+strconv.Itoa(int(pid))).Output()
if err == nil {
// Output will be something like this:
//
@ -21,6 +21,8 @@ func CheckProcessAndKill(pid uint64, processName string) {
// ========================= ======== ================ =========== ============
// process.exe <PID> Services 0 8,936 K
lines := strings.Split(string(bytes),"\n")
log.Debugf(lines)
// check for "<process>.exe"
if len(lines) >= 3 && strings.HasPrefix(strings.ToLower(strings.TrimSpace(lines[2])),processName+".exe") {
Kill(pid)