diff --git a/common/common_darwin.go b/common/common_darwin.go index 8d43de0..cc74601 100644 --- a/common/common_darwin.go +++ b/common/common_darwin.go @@ -68,7 +68,11 @@ func CallLsof(invoke Invoker, pid int32, args ...string) ([]string, error) { cmd = []string{"-a", "-n", "-P", "-p", strconv.Itoa(int(pid))} } cmd = append(cmd, args...) - out, err := invoke.Command("/usr/sbin/lsof", cmd...) + lsof, err := exec.LookPath("lsof") + if err != nil { + return []string{}, err + } + out, err := invoke.Command(lsof, cmd...) if err != nil { return []string{}, err } diff --git a/common/common_linux.go b/common/common_linux.go index bec024f..3c760e5 100644 --- a/common/common_linux.go +++ b/common/common_linux.go @@ -3,6 +3,7 @@ package common import ( + "os/exec" "strconv" "strings" ) @@ -15,7 +16,11 @@ func CallLsof(invoke Invoker, pid int32, args ...string) ([]string, error) { cmd = []string{"-a", "-n", "-P", "-p", strconv.Itoa(int(pid))} } cmd = append(cmd, args...) - out, err := invoke.Command("/usr/bin/lsof", cmd...) + lsof, err := exec.LookPath("lsof") + if err != nil { + return []string{}, err + } + out, err := invoke.Command(lsof, cmd...) if err != nil { return []string{}, err } diff --git a/net/net_linux.go b/net/net_linux.go index 54971f9..de0d65a 100644 --- a/net/net_linux.go +++ b/net/net_linux.go @@ -3,7 +3,6 @@ package net import ( - "fmt" "strconv" "strings" @@ -135,7 +134,7 @@ func NetConnections(kind string) ([]NetConnectionStat, error) { } n, err := parseNetLine(rr) if err != nil { - fmt.Println(err) // TODO: should debug print? + // fmt.Println(err) // TODO: should debug print? continue }