use LookPath

pull/77/head
Shirou WAKAYAMA 10 years ago
parent 249a761b81
commit 0062ae2bfa

@ -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
}

@ -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
}

@ -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
}

Loading…
Cancel
Save