From 97bcc355a68071cd95d1a72a7a5a3914d59a53b1 Mon Sep 17 00:00:00 2001 From: Shirou WAKAYAMA Date: Tue, 23 Feb 2016 15:13:24 +0900 Subject: [PATCH] [process]linux: change to use exec.LookPath to invoke lsof. --- process/process_linux.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/process/process_linux.go b/process/process_linux.go index 05a75c9..1783d2f 100644 --- a/process/process_linux.go +++ b/process/process_linux.go @@ -8,6 +8,7 @@ import ( "fmt" "io/ioutil" "os" + "os/exec" "path/filepath" "strconv" "strings" @@ -673,7 +674,11 @@ func callLsof(arg string, pid int32) ([]string, error) { } else { cmd = []string{"-a", "-F" + arg, "-p", strconv.Itoa(int(pid))} } - 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 } -- GitLab