summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/shirou/gopsutil/internal/common/common_unix.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/shirou/gopsutil/internal/common/common_unix.go')
-rw-r--r--vendor/github.com/shirou/gopsutil/internal/common/common_unix.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/vendor/github.com/shirou/gopsutil/internal/common/common_unix.go b/vendor/github.com/shirou/gopsutil/internal/common/common_unix.go
index cc934dd..750a592 100644
--- a/vendor/github.com/shirou/gopsutil/internal/common/common_unix.go
+++ b/vendor/github.com/shirou/gopsutil/internal/common/common_unix.go
@@ -3,12 +3,13 @@
package common
import (
+ "context"
"os/exec"
"strconv"
"strings"
)
-func CallLsof(invoke Invoker, pid int32, args ...string) ([]string, error) {
+func CallLsofWithContext(ctx context.Context, invoke Invoker, pid int32, args ...string) ([]string, error) {
var cmd []string
if pid == 0 { // will get from all processes.
cmd = []string{"-a", "-n", "-P"}
@@ -20,7 +21,7 @@ func CallLsof(invoke Invoker, pid int32, args ...string) ([]string, error) {
if err != nil {
return []string{}, err
}
- out, err := invoke.Command(lsof, cmd...)
+ out, err := invoke.CommandWithContext(ctx, lsof, cmd...)
if err != nil {
// if no pid found, lsof returnes code 1.
if err.Error() == "exit status 1" && len(out) == 0 {
@@ -39,14 +40,14 @@ func CallLsof(invoke Invoker, pid int32, args ...string) ([]string, error) {
return ret, nil
}
-func CallPgrep(invoke Invoker, pid int32) ([]int32, error) {
+func CallPgrepWithContext(ctx context.Context, invoke Invoker, pid int32) ([]int32, error) {
var cmd []string
cmd = []string{"-P", strconv.Itoa(int(pid))}
pgrep, err := exec.LookPath("pgrep")
if err != nil {
return []int32{}, err
}
- out, err := invoke.Command(pgrep, cmd...)
+ out, err := invoke.CommandWithContext(ctx, pgrep, cmd...)
if err != nil {
return []int32{}, err
}