mirror of
https://github.com/shirou/gopsutil.git
synced 2025-04-29 13:49:21 +08:00
[process]linux: change to use exec.LookPath to invoke lsof.
This commit is contained in:
parent
821a0141b1
commit
97bcc355a6
@ -8,6 +8,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -673,7 +674,11 @@ func callLsof(arg string, pid int32) ([]string, error) {
|
|||||||
} else {
|
} else {
|
||||||
cmd = []string{"-a", "-F" + arg, "-p", strconv.Itoa(int(pid))}
|
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 {
|
if err != nil {
|
||||||
return []string{}, err
|
return []string{}, err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user