summaryrefslogtreecommitdiff
path: root/vendor/github.com/shirou/gopsutil/v4/process
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-05-14 13:18:54 -0600
committermo khan <mo@mokhan.ca>2025-05-14 13:18:54 -0600
commit4b2d609a0efcc1d9b2f1a08f954d067ad1d9cd1e (patch)
tree0afacf9217b0569130da6b97d4197331681bf119 /vendor/github.com/shirou/gopsutil/v4/process
parentab373d1fe698cd3f53258c09bc8515d88a6d0b9e (diff)
test: use playwright to test out an OIDC login
Diffstat (limited to 'vendor/github.com/shirou/gopsutil/v4/process')
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/process/process.go29
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/process/process_bsd.go26
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/process/process_darwin.go52
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/process/process_fallback.go86
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/process/process_freebsd.go32
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/process/process_linux.go4
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/process/process_openbsd.go44
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/process/process_plan9.go86
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/process/process_posix.go4
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/process/process_solaris.go63
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/process/process_windows.go146
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/process/process_windows_32bit.go74
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/process/process_windows_64bit.go36
13 files changed, 354 insertions, 328 deletions
diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process.go b/vendor/github.com/shirou/gopsutil/v4/process/process.go
index 70411c6..0bd4d9e 100644
--- a/vendor/github.com/shirou/gopsutil/v4/process/process.go
+++ b/vendor/github.com/shirou/gopsutil/v4/process/process.go
@@ -269,13 +269,11 @@ func (p *Process) PercentWithContext(ctx context.Context, interval time.Duration
if err != nil {
return 0, err
}
- } else {
- if p.lastCPUTimes == nil {
- // invoked first time
- p.lastCPUTimes = cpuTimes
- p.lastCPUTime = now
- return 0, nil
- }
+ } else if p.lastCPUTimes == nil {
+ // invoked first time
+ p.lastCPUTimes = cpuTimes
+ p.lastCPUTime = now
+ return 0, nil
}
numcpu := runtime.NumCPU()
@@ -326,12 +324,12 @@ func calculatePercent(t1, t2 *cpu.TimesStat, delta float64, numcpu int) float64
return 0
}
// https://github.com/giampaolo/psutil/blob/c034e6692cf736b5e87d14418a8153bb03f6cf42/psutil/__init__.py#L1064
- delta_proc := (t2.User - t1.User) + (t2.System - t1.System)
- if delta_proc <= 0 {
+ deltaProc := (t2.User - t1.User) + (t2.System - t1.System)
+ if deltaProc <= 0 {
return 0
}
- overall_percent := ((delta_proc / delta) * 100) * float64(numcpu)
- return overall_percent
+ overallPercent := ((deltaProc / delta) * 100) * float64(numcpu)
+ return overallPercent
}
// MemoryPercent returns how many percent of the total RAM this process uses
@@ -361,7 +359,7 @@ func (p *Process) CPUPercent() (float64, error) {
}
func (p *Process) CPUPercentWithContext(ctx context.Context) (float64, error) {
- crt_time, err := p.createTimeWithContext(ctx)
+ createTime, err := p.createTimeWithContext(ctx)
if err != nil {
return 0, err
}
@@ -371,7 +369,7 @@ func (p *Process) CPUPercentWithContext(ctx context.Context) (float64, error) {
return 0, err
}
- created := time.Unix(0, crt_time*int64(time.Millisecond))
+ created := time.Unix(0, createTime*int64(time.Millisecond))
totalTime := time.Since(created).Seconds()
if totalTime <= 0 {
return 0, nil
@@ -408,6 +406,11 @@ func (p *Process) Cmdline() (string, error) {
// CmdlineSlice returns the command line arguments of the process as a slice with each
// element being an argument.
+//
+// On Windows, this assumes the command line is encoded according to the convention accepted by
+// [golang.org/x/sys/windows.CmdlineToArgv] (the most common convention). If this is not suitable,
+// you should instead use [Process.Cmdline] and parse the command line according to your specific
+// requirements.
func (p *Process) CmdlineSlice() ([]string, error) {
return p.CmdlineSliceWithContext(context.Background())
}
diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_bsd.go b/vendor/github.com/shirou/gopsutil/v4/process/process_bsd.go
index dcc0561..1a58c3e 100644
--- a/vendor/github.com/shirou/gopsutil/v4/process/process_bsd.go
+++ b/vendor/github.com/shirou/gopsutil/v4/process/process_bsd.go
@@ -16,55 +16,55 @@ type MemoryInfoExStat struct{}
type MemoryMapsStat struct{}
-func (p *Process) TgidWithContext(ctx context.Context) (int32, error) {
+func (p *Process) TgidWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) IOniceWithContext(ctx context.Context) (int32, error) {
+func (p *Process) IOniceWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) RlimitWithContext(ctx context.Context) ([]RlimitStat, error) {
+func (p *Process) RlimitWithContext(_ context.Context) ([]RlimitStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) RlimitUsageWithContext(ctx context.Context, gatherUsed bool) ([]RlimitStat, error) {
+func (p *Process) RlimitUsageWithContext(_ context.Context, _ bool) ([]RlimitStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) NumCtxSwitchesWithContext(ctx context.Context) (*NumCtxSwitchesStat, error) {
+func (p *Process) NumCtxSwitchesWithContext(_ context.Context) (*NumCtxSwitchesStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) NumFDsWithContext(ctx context.Context) (int32, error) {
+func (p *Process) NumFDsWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) CPUAffinityWithContext(ctx context.Context) ([]int32, error) {
+func (p *Process) CPUAffinityWithContext(_ context.Context) ([]int32, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) MemoryInfoExWithContext(ctx context.Context) (*MemoryInfoExStat, error) {
+func (p *Process) MemoryInfoExWithContext(_ context.Context) (*MemoryInfoExStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) PageFaultsWithContext(ctx context.Context) (*PageFaultsStat, error) {
+func (p *Process) PageFaultsWithContext(_ context.Context) (*PageFaultsStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) OpenFilesWithContext(ctx context.Context) ([]OpenFilesStat, error) {
+func (p *Process) OpenFilesWithContext(_ context.Context) ([]OpenFilesStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) MemoryMapsWithContext(ctx context.Context, grouped bool) (*[]MemoryMapsStat, error) {
+func (p *Process) MemoryMapsWithContext(_ context.Context, _ bool) (*[]MemoryMapsStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) ThreadsWithContext(ctx context.Context) (map[int32]*cpu.TimesStat, error) {
+func (p *Process) ThreadsWithContext(_ context.Context) (map[int32]*cpu.TimesStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) EnvironWithContext(ctx context.Context) ([]string, error) {
+func (p *Process) EnvironWithContext(_ context.Context) ([]string, error) {
return nil, common.ErrNotImplementedError
}
diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_darwin.go b/vendor/github.com/shirou/gopsutil/v4/process/process_darwin.go
index 33abc10..5afafd8 100644
--- a/vendor/github.com/shirou/gopsutil/v4/process/process_darwin.go
+++ b/vendor/github.com/shirou/gopsutil/v4/process/process_darwin.go
@@ -7,6 +7,7 @@ import (
"bytes"
"context"
"encoding/binary"
+ "errors"
"fmt"
"path/filepath"
"runtime"
@@ -32,11 +33,11 @@ const (
KernProcPathname = 12 // path to executable
)
-type _Ctype_struct___0 struct {
+type _Ctype_struct___0 struct { //nolint:revive //FIXME
Pad uint64
}
-func pidsWithContext(ctx context.Context) ([]int32, error) {
+func pidsWithContext(_ context.Context) ([]int32, error) {
var ret []int32
kprocs, err := unix.SysctlKinfoProcSlice("kern.proc.all")
@@ -51,7 +52,7 @@ func pidsWithContext(ctx context.Context) ([]int32, error) {
return ret, nil
}
-func (p *Process) PpidWithContext(ctx context.Context) (int32, error) {
+func (p *Process) PpidWithContext(_ context.Context) (int32, error) {
k, err := p.getKProc()
if err != nil {
return 0, err
@@ -84,7 +85,7 @@ func (p *Process) NameWithContext(ctx context.Context) (string, error) {
return name, nil
}
-func (p *Process) createTimeWithContext(ctx context.Context) (int64, error) {
+func (p *Process) createTimeWithContext(_ context.Context) (int64, error) {
k, err := p.getKProc()
if err != nil {
return 0, err
@@ -112,7 +113,7 @@ func (p *Process) ForegroundWithContext(ctx context.Context) (bool, error) {
return strings.IndexByte(string(out), '+') != -1, nil
}
-func (p *Process) UidsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) UidsWithContext(_ context.Context) ([]uint32, error) {
k, err := p.getKProc()
if err != nil {
return nil, err
@@ -124,7 +125,7 @@ func (p *Process) UidsWithContext(ctx context.Context) ([]uint32, error) {
return []uint32{userEffectiveUID}, nil
}
-func (p *Process) GidsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) GidsWithContext(_ context.Context) ([]uint32, error) {
k, err := p.getKProc()
if err != nil {
return nil, err
@@ -136,7 +137,7 @@ func (p *Process) GidsWithContext(ctx context.Context) ([]uint32, error) {
return gids, nil
}
-func (p *Process) GroupsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) GroupsWithContext(_ context.Context) ([]uint32, error) {
return nil, common.ErrNotImplementedError
// k, err := p.getKProc()
// if err != nil {
@@ -151,7 +152,7 @@ func (p *Process) GroupsWithContext(ctx context.Context) ([]uint32, error) {
// return groups, nil
}
-func (p *Process) TerminalWithContext(ctx context.Context) (string, error) {
+func (p *Process) TerminalWithContext(_ context.Context) (string, error) {
return "", common.ErrNotImplementedError
/*
k, err := p.getKProc()
@@ -169,7 +170,7 @@ func (p *Process) TerminalWithContext(ctx context.Context) (string, error) {
*/
}
-func (p *Process) NiceWithContext(ctx context.Context) (int32, error) {
+func (p *Process) NiceWithContext(_ context.Context) (int32, error) {
k, err := p.getKProc()
if err != nil {
return 0, err
@@ -177,7 +178,7 @@ func (p *Process) NiceWithContext(ctx context.Context) (int32, error) {
return int32(k.Proc.P_nice), nil
}
-func (p *Process) IOCountersWithContext(ctx context.Context) (*IOCountersStat, error) {
+func (p *Process) IOCountersWithContext(_ context.Context) (*IOCountersStat, error) {
return nil, common.ErrNotImplementedError
}
@@ -239,11 +240,12 @@ func (p *Process) getKProc() (*unix.KinfoProc, error) {
// If passed arg pid is 0, get information from all process.
func callPsWithContext(ctx context.Context, arg string, pid int32, threadOption bool, nameOption bool) ([][]string, error) {
var cmd []string
- if pid == 0 { // will get from all processes.
+ switch {
+ case pid == 0: // will get from all processes.
cmd = []string{"-ax", "-o", arg}
- } else if threadOption {
+ case threadOption:
cmd = []string{"-x", "-o", arg, "-M", "-p", strconv.Itoa(int(pid))}
- } else {
+ default:
cmd = []string{"-x", "-o", arg, "-p", strconv.Itoa(int(pid))}
}
if nameOption {
@@ -303,7 +305,7 @@ func getTimeScaleToNanoSeconds() float64 {
return float64(timeBaseInfo.Numer) / float64(timeBaseInfo.Denom)
}
-func (p *Process) ExeWithContext(ctx context.Context) (string, error) {
+func (p *Process) ExeWithContext(_ context.Context) (string, error) {
lib, err := registerFuncs()
if err != nil {
return "", err
@@ -332,7 +334,7 @@ type vnodePathInfo struct {
// EUID can access. Otherwise "operation not permitted" will be returned as the
// error.
// Note: This might also work for other *BSD OSs.
-func (p *Process) CwdWithContext(ctx context.Context) (string, error) {
+func (p *Process) CwdWithContext(_ context.Context) (string, error) {
lib, err := registerFuncs()
if err != nil {
return "", err
@@ -348,7 +350,7 @@ func (p *Process) CwdWithContext(ctx context.Context) (string, error) {
ret := procPidInfo(p.Pid, common.PROC_PIDVNODEPATHINFO, 0, uintptr(unsafe.Pointer(&vpi)), vpiSize)
errno, _ := lib.Dlsym("errno")
err = *(**unix.Errno)(unsafe.Pointer(&errno))
- if err == unix.EPERM {
+ if errors.Is(err, unix.EPERM) {
return "", ErrorNotPermitted
}
@@ -373,11 +375,11 @@ func procArgs(pid int32) ([]byte, int, error) {
return procargs, int(binary.LittleEndian.Uint32(nargs)), nil
}
-func (p *Process) CmdlineSliceWithContext(ctx context.Context) ([]string, error) {
- return p.cmdlineSliceWithContext(ctx, true)
+func (p *Process) CmdlineSliceWithContext(_ context.Context) ([]string, error) {
+ return p.cmdlineSlice()
}
-func (p *Process) cmdlineSliceWithContext(ctx context.Context, fallback bool) ([]string, error) {
+func (p *Process) cmdlineSlice() ([]string, error) {
pargs, nargs, err := procArgs(p.Pid)
if err != nil {
return nil, err
@@ -393,7 +395,7 @@ func (p *Process) cmdlineSliceWithContext(ctx context.Context, fallback bool) ([
// are the arguments. Everything else in the slice is then the environment
// of the process.
for _, arg := range args[1:] {
- argStr = string(arg[:])
+ argStr = string(arg)
if len(argStr) > 0 {
if nargs > 0 {
argSlice = append(argSlice, argStr)
@@ -408,8 +410,8 @@ func (p *Process) cmdlineSliceWithContext(ctx context.Context, fallback bool) ([
}
// cmdNameWithContext returns the command name (including spaces) without any arguments
-func (p *Process) cmdNameWithContext(ctx context.Context) (string, error) {
- r, err := p.cmdlineSliceWithContext(ctx, false)
+func (p *Process) cmdNameWithContext(_ context.Context) (string, error) {
+ r, err := p.cmdlineSlice()
if err != nil {
return "", err
}
@@ -429,7 +431,7 @@ func (p *Process) CmdlineWithContext(ctx context.Context) (string, error) {
return strings.Join(r, " "), err
}
-func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) {
+func (p *Process) NumThreadsWithContext(_ context.Context) (int32, error) {
lib, err := registerFuncs()
if err != nil {
return 0, err
@@ -442,7 +444,7 @@ func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) {
return int32(ti.Threadnum), nil
}
-func (p *Process) TimesWithContext(ctx context.Context) (*cpu.TimesStat, error) {
+func (p *Process) TimesWithContext(_ context.Context) (*cpu.TimesStat, error) {
lib, err := registerFuncs()
if err != nil {
return nil, err
@@ -461,7 +463,7 @@ func (p *Process) TimesWithContext(ctx context.Context) (*cpu.TimesStat, error)
return ret, nil
}
-func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, error) {
+func (p *Process) MemoryInfoWithContext(_ context.Context) (*MemoryInfoStat, error) {
lib, err := registerFuncs()
if err != nil {
return nil, err
diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_fallback.go b/vendor/github.com/shirou/gopsutil/v4/process/process_fallback.go
index e5410ea..b014297 100644
--- a/vendor/github.com/shirou/gopsutil/v4/process/process_fallback.go
+++ b/vendor/github.com/shirou/gopsutil/v4/process/process_fallback.go
@@ -30,174 +30,174 @@ type MemoryMapsStat struct {
type MemoryInfoExStat struct{}
-func pidsWithContext(ctx context.Context) ([]int32, error) {
+func pidsWithContext(_ context.Context) ([]int32, error) {
return nil, common.ErrNotImplementedError
}
-func ProcessesWithContext(ctx context.Context) ([]*Process, error) {
+func ProcessesWithContext(_ context.Context) ([]*Process, error) {
return nil, common.ErrNotImplementedError
}
-func PidExistsWithContext(ctx context.Context, pid int32) (bool, error) {
+func PidExistsWithContext(_ context.Context, _ int32) (bool, error) {
return false, common.ErrNotImplementedError
}
-func (p *Process) PpidWithContext(ctx context.Context) (int32, error) {
+func (p *Process) PpidWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) NameWithContext(ctx context.Context) (string, error) {
+func (p *Process) NameWithContext(_ context.Context) (string, error) {
return "", common.ErrNotImplementedError
}
-func (p *Process) TgidWithContext(ctx context.Context) (int32, error) {
+func (p *Process) TgidWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) ExeWithContext(ctx context.Context) (string, error) {
+func (p *Process) ExeWithContext(_ context.Context) (string, error) {
return "", common.ErrNotImplementedError
}
-func (p *Process) CmdlineWithContext(ctx context.Context) (string, error) {
+func (p *Process) CmdlineWithContext(_ context.Context) (string, error) {
return "", common.ErrNotImplementedError
}
-func (p *Process) CmdlineSliceWithContext(ctx context.Context) ([]string, error) {
+func (p *Process) CmdlineSliceWithContext(_ context.Context) ([]string, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) createTimeWithContext(ctx context.Context) (int64, error) {
+func (p *Process) createTimeWithContext(_ context.Context) (int64, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) CwdWithContext(ctx context.Context) (string, error) {
+func (p *Process) CwdWithContext(_ context.Context) (string, error) {
return "", common.ErrNotImplementedError
}
-func (p *Process) StatusWithContext(ctx context.Context) ([]string, error) {
+func (p *Process) StatusWithContext(_ context.Context) ([]string, error) {
return []string{""}, common.ErrNotImplementedError
}
-func (p *Process) ForegroundWithContext(ctx context.Context) (bool, error) {
+func (p *Process) ForegroundWithContext(_ context.Context) (bool, error) {
return false, common.ErrNotImplementedError
}
-func (p *Process) UidsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) UidsWithContext(_ context.Context) ([]uint32, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) GidsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) GidsWithContext(_ context.Context) ([]uint32, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) GroupsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) GroupsWithContext(_ context.Context) ([]uint32, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) TerminalWithContext(ctx context.Context) (string, error) {
+func (p *Process) TerminalWithContext(_ context.Context) (string, error) {
return "", common.ErrNotImplementedError
}
-func (p *Process) NiceWithContext(ctx context.Context) (int32, error) {
+func (p *Process) NiceWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) IOniceWithContext(ctx context.Context) (int32, error) {
+func (p *Process) IOniceWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) RlimitWithContext(ctx context.Context) ([]RlimitStat, error) {
+func (p *Process) RlimitWithContext(_ context.Context) ([]RlimitStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) RlimitUsageWithContext(ctx context.Context, gatherUsed bool) ([]RlimitStat, error) {
+func (p *Process) RlimitUsageWithContext(_ context.Context, _ bool) ([]RlimitStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) IOCountersWithContext(ctx context.Context) (*IOCountersStat, error) {
+func (p *Process) IOCountersWithContext(_ context.Context) (*IOCountersStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) NumCtxSwitchesWithContext(ctx context.Context) (*NumCtxSwitchesStat, error) {
+func (p *Process) NumCtxSwitchesWithContext(_ context.Context) (*NumCtxSwitchesStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) NumFDsWithContext(ctx context.Context) (int32, error) {
+func (p *Process) NumFDsWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) {
+func (p *Process) NumThreadsWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) ThreadsWithContext(ctx context.Context) (map[int32]*cpu.TimesStat, error) {
+func (p *Process) ThreadsWithContext(_ context.Context) (map[int32]*cpu.TimesStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) TimesWithContext(ctx context.Context) (*cpu.TimesStat, error) {
+func (p *Process) TimesWithContext(_ context.Context) (*cpu.TimesStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) CPUAffinityWithContext(ctx context.Context) ([]int32, error) {
+func (p *Process) CPUAffinityWithContext(_ context.Context) ([]int32, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, error) {
+func (p *Process) MemoryInfoWithContext(_ context.Context) (*MemoryInfoStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) MemoryInfoExWithContext(ctx context.Context) (*MemoryInfoExStat, error) {
+func (p *Process) MemoryInfoExWithContext(_ context.Context) (*MemoryInfoExStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) PageFaultsWithContext(ctx context.Context) (*PageFaultsStat, error) {
+func (p *Process) PageFaultsWithContext(_ context.Context) (*PageFaultsStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) ChildrenWithContext(ctx context.Context) ([]*Process, error) {
+func (p *Process) ChildrenWithContext(_ context.Context) ([]*Process, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) OpenFilesWithContext(ctx context.Context) ([]OpenFilesStat, error) {
+func (p *Process) OpenFilesWithContext(_ context.Context) ([]OpenFilesStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) ConnectionsWithContext(ctx context.Context) ([]net.ConnectionStat, error) {
+func (p *Process) ConnectionsWithContext(_ context.Context) ([]net.ConnectionStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) ConnectionsMaxWithContext(ctx context.Context, maxConn int) ([]net.ConnectionStat, error) {
+func (p *Process) ConnectionsMaxWithContext(_ context.Context, _ int) ([]net.ConnectionStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) MemoryMapsWithContext(ctx context.Context, grouped bool) (*[]MemoryMapsStat, error) {
+func (p *Process) MemoryMapsWithContext(_ context.Context, _ bool) (*[]MemoryMapsStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) SendSignalWithContext(ctx context.Context, sig Signal) error {
+func (p *Process) SendSignalWithContext(_ context.Context, _ Signal) error {
return common.ErrNotImplementedError
}
-func (p *Process) SuspendWithContext(ctx context.Context) error {
+func (p *Process) SuspendWithContext(_ context.Context) error {
return common.ErrNotImplementedError
}
-func (p *Process) ResumeWithContext(ctx context.Context) error {
+func (p *Process) ResumeWithContext(_ context.Context) error {
return common.ErrNotImplementedError
}
-func (p *Process) TerminateWithContext(ctx context.Context) error {
+func (p *Process) TerminateWithContext(_ context.Context) error {
return common.ErrNotImplementedError
}
-func (p *Process) KillWithContext(ctx context.Context) error {
+func (p *Process) KillWithContext(_ context.Context) error {
return common.ErrNotImplementedError
}
-func (p *Process) UsernameWithContext(ctx context.Context) (string, error) {
+func (p *Process) UsernameWithContext(_ context.Context) (string, error) {
return "", common.ErrNotImplementedError
}
-func (p *Process) EnvironWithContext(ctx context.Context) ([]string, error) {
+func (p *Process) EnvironWithContext(_ context.Context) ([]string, error) {
return nil, common.ErrNotImplementedError
}
diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_freebsd.go b/vendor/github.com/shirou/gopsutil/v4/process/process_freebsd.go
index a67ac0e..6df3142 100644
--- a/vendor/github.com/shirou/gopsutil/v4/process/process_freebsd.go
+++ b/vendor/github.com/shirou/gopsutil/v4/process/process_freebsd.go
@@ -34,7 +34,7 @@ func pidsWithContext(ctx context.Context) ([]int32, error) {
return ret, nil
}
-func (p *Process) PpidWithContext(ctx context.Context) (int32, error) {
+func (p *Process) PpidWithContext(_ context.Context) (int32, error) {
k, err := p.getKProc()
if err != nil {
return 0, err
@@ -66,7 +66,7 @@ func (p *Process) NameWithContext(ctx context.Context) (string, error) {
return name, nil
}
-func (p *Process) CwdWithContext(ctx context.Context) (string, error) {
+func (p *Process) CwdWithContext(_ context.Context) (string, error) {
mib := []int32{CTLKern, KernProc, KernProcCwd, p.Pid}
buf, length, err := common.CallSyscall(mib)
if err != nil {
@@ -87,7 +87,7 @@ func (p *Process) CwdWithContext(ctx context.Context) (string, error) {
return cwd, nil
}
-func (p *Process) ExeWithContext(ctx context.Context) (string, error) {
+func (p *Process) ExeWithContext(_ context.Context) (string, error) {
mib := []int32{CTLKern, KernProc, KernProcPathname, p.Pid}
buf, _, err := common.CallSyscall(mib)
if err != nil {
@@ -97,7 +97,7 @@ func (p *Process) ExeWithContext(ctx context.Context) (string, error) {
return strings.Trim(string(buf), "\x00"), nil
}
-func (p *Process) CmdlineWithContext(ctx context.Context) (string, error) {
+func (p *Process) CmdlineWithContext(_ context.Context) (string, error) {
mib := []int32{CTLKern, KernProc, KernProcArgs, p.Pid}
buf, _, err := common.CallSyscall(mib)
if err != nil {
@@ -110,7 +110,7 @@ func (p *Process) CmdlineWithContext(ctx context.Context) (string, error) {
return strings.Join(ret, " "), nil
}
-func (p *Process) CmdlineSliceWithContext(ctx context.Context) ([]string, error) {
+func (p *Process) CmdlineSliceWithContext(_ context.Context) ([]string, error) {
mib := []int32{CTLKern, KernProc, KernProcArgs, p.Pid}
buf, _, err := common.CallSyscall(mib)
if err != nil {
@@ -131,7 +131,7 @@ func (p *Process) CmdlineSliceWithContext(ctx context.Context) ([]string, error)
return strParts, nil
}
-func (p *Process) createTimeWithContext(ctx context.Context) (int64, error) {
+func (p *Process) createTimeWithContext(_ context.Context) (int64, error) {
k, err := p.getKProc()
if err != nil {
return 0, err
@@ -139,7 +139,7 @@ func (p *Process) createTimeWithContext(ctx context.Context) (int64, error) {
return int64(k.Start.Sec)*1000 + int64(k.Start.Usec)/1000, nil
}
-func (p *Process) StatusWithContext(ctx context.Context) ([]string, error) {
+func (p *Process) StatusWithContext(_ context.Context) ([]string, error) {
k, err := p.getKProc()
if err != nil {
return []string{""}, err
@@ -175,7 +175,7 @@ func (p *Process) ForegroundWithContext(ctx context.Context) (bool, error) {
return strings.IndexByte(string(out), '+') != -1, nil
}
-func (p *Process) UidsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) UidsWithContext(_ context.Context) ([]uint32, error) {
k, err := p.getKProc()
if err != nil {
return nil, err
@@ -188,7 +188,7 @@ func (p *Process) UidsWithContext(ctx context.Context) ([]uint32, error) {
return uids, nil
}
-func (p *Process) GidsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) GidsWithContext(_ context.Context) ([]uint32, error) {
k, err := p.getKProc()
if err != nil {
return nil, err
@@ -200,7 +200,7 @@ func (p *Process) GidsWithContext(ctx context.Context) ([]uint32, error) {
return gids, nil
}
-func (p *Process) GroupsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) GroupsWithContext(_ context.Context) ([]uint32, error) {
k, err := p.getKProc()
if err != nil {
return nil, err
@@ -214,7 +214,7 @@ func (p *Process) GroupsWithContext(ctx context.Context) ([]uint32, error) {
return groups, nil
}
-func (p *Process) TerminalWithContext(ctx context.Context) (string, error) {
+func (p *Process) TerminalWithContext(_ context.Context) (string, error) {
k, err := p.getKProc()
if err != nil {
return "", err
@@ -230,7 +230,7 @@ func (p *Process) TerminalWithContext(ctx context.Context) (string, error) {
return termmap[ttyNr], nil
}
-func (p *Process) NiceWithContext(ctx context.Context) (int32, error) {
+func (p *Process) NiceWithContext(_ context.Context) (int32, error) {
k, err := p.getKProc()
if err != nil {
return 0, err
@@ -238,7 +238,7 @@ func (p *Process) NiceWithContext(ctx context.Context) (int32, error) {
return int32(k.Nice), nil
}
-func (p *Process) IOCountersWithContext(ctx context.Context) (*IOCountersStat, error) {
+func (p *Process) IOCountersWithContext(_ context.Context) (*IOCountersStat, error) {
k, err := p.getKProc()
if err != nil {
return nil, err
@@ -249,7 +249,7 @@ func (p *Process) IOCountersWithContext(ctx context.Context) (*IOCountersStat, e
}, nil
}
-func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) {
+func (p *Process) NumThreadsWithContext(_ context.Context) (int32, error) {
k, err := p.getKProc()
if err != nil {
return 0, err
@@ -258,7 +258,7 @@ func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) {
return k.Numthreads, nil
}
-func (p *Process) TimesWithContext(ctx context.Context) (*cpu.TimesStat, error) {
+func (p *Process) TimesWithContext(_ context.Context) (*cpu.TimesStat, error) {
k, err := p.getKProc()
if err != nil {
return nil, err
@@ -270,7 +270,7 @@ func (p *Process) TimesWithContext(ctx context.Context) (*cpu.TimesStat, error)
}, nil
}
-func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, error) {
+func (p *Process) MemoryInfoWithContext(_ context.Context) (*MemoryInfoStat, error) {
k, err := p.getKProc()
if err != nil {
return nil, err
diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_linux.go b/vendor/github.com/shirou/gopsutil/v4/process/process_linux.go
index 68a8c88..bf96fd3 100644
--- a/vendor/github.com/shirou/gopsutil/v4/process/process_linux.go
+++ b/vendor/github.com/shirou/gopsutil/v4/process/process_linux.go
@@ -194,7 +194,7 @@ func (p *Process) NiceWithContext(ctx context.Context) (int32, error) {
return nice, nil
}
-func (p *Process) IOniceWithContext(ctx context.Context) (int32, error) {
+func (p *Process) IOniceWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
@@ -310,7 +310,7 @@ func (p *Process) TimesWithContext(ctx context.Context) (*cpu.TimesStat, error)
return cpuTimes, nil
}
-func (p *Process) CPUAffinityWithContext(ctx context.Context) ([]int32, error) {
+func (p *Process) CPUAffinityWithContext(_ context.Context) ([]int32, error) {
return nil, common.ErrNotImplementedError
}
diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_openbsd.go b/vendor/github.com/shirou/gopsutil/v4/process/process_openbsd.go
index 5e8a9e0..5a6d361 100644
--- a/vendor/github.com/shirou/gopsutil/v4/process/process_openbsd.go
+++ b/vendor/github.com/shirou/gopsutil/v4/process/process_openbsd.go
@@ -8,7 +8,6 @@ import (
"context"
"encoding/binary"
"errors"
- "fmt"
"io"
"path/filepath"
"sort"
@@ -16,11 +15,12 @@ import (
"strings"
"unsafe"
- cpu "github.com/shirou/gopsutil/v4/cpu"
- "github.com/shirou/gopsutil/v4/internal/common"
- mem "github.com/shirou/gopsutil/v4/mem"
- net "github.com/shirou/gopsutil/v4/net"
"golang.org/x/sys/unix"
+
+ "github.com/shirou/gopsutil/v4/cpu"
+ "github.com/shirou/gopsutil/v4/internal/common"
+ "github.com/shirou/gopsutil/v4/mem"
+ "github.com/shirou/gopsutil/v4/net"
)
func pidsWithContext(ctx context.Context) ([]int32, error) {
@@ -37,7 +37,7 @@ func pidsWithContext(ctx context.Context) ([]int32, error) {
return ret, nil
}
-func (p *Process) PpidWithContext(ctx context.Context) (int32, error) {
+func (p *Process) PpidWithContext(_ context.Context) (int32, error) {
k, err := p.getKProc()
if err != nil {
return 0, err
@@ -69,7 +69,7 @@ func (p *Process) NameWithContext(ctx context.Context) (string, error) {
return name, nil
}
-func (p *Process) CwdWithContext(ctx context.Context) (string, error) {
+func (p *Process) CwdWithContext(_ context.Context) (string, error) {
mib := []int32{CTLKern, KernProcCwd, p.Pid}
buf, _, err := common.CallSyscall(mib)
if err != nil {
@@ -78,11 +78,11 @@ func (p *Process) CwdWithContext(ctx context.Context) (string, error) {
return common.ByteToString(buf), nil
}
-func (p *Process) ExeWithContext(ctx context.Context) (string, error) {
+func (p *Process) ExeWithContext(_ context.Context) (string, error) {
return "", common.ErrNotImplementedError
}
-func (p *Process) CmdlineSliceWithContext(ctx context.Context) ([]string, error) {
+func (p *Process) CmdlineSliceWithContext(_ context.Context) ([]string, error) {
mib := []int32{CTLKern, KernProcArgs, p.Pid, KernProcArgv}
buf, _, err := common.CallSyscall(mib)
if err != nil {
@@ -130,7 +130,7 @@ func readPtr(r io.Reader) (uintptr, error) {
}
return uintptr(p), nil
default:
- return 0, fmt.Errorf("unsupported pointer size")
+ return 0, errors.New("unsupported pointer size")
}
}
@@ -142,11 +142,11 @@ func (p *Process) CmdlineWithContext(ctx context.Context) (string, error) {
return strings.Join(argv, " "), nil
}
-func (p *Process) createTimeWithContext(ctx context.Context) (int64, error) {
+func (p *Process) createTimeWithContext(_ context.Context) (int64, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) StatusWithContext(ctx context.Context) ([]string, error) {
+func (p *Process) StatusWithContext(_ context.Context) ([]string, error) {
k, err := p.getKProc()
if err != nil {
return []string{""}, err
@@ -178,7 +178,7 @@ func (p *Process) ForegroundWithContext(ctx context.Context) (bool, error) {
return strings.IndexByte(string(out), '+') != -1, nil
}
-func (p *Process) UidsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) UidsWithContext(_ context.Context) ([]uint32, error) {
k, err := p.getKProc()
if err != nil {
return nil, err
@@ -191,7 +191,7 @@ func (p *Process) UidsWithContext(ctx context.Context) ([]uint32, error) {
return uids, nil
}
-func (p *Process) GidsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) GidsWithContext(_ context.Context) ([]uint32, error) {
k, err := p.getKProc()
if err != nil {
return nil, err
@@ -203,7 +203,7 @@ func (p *Process) GidsWithContext(ctx context.Context) ([]uint32, error) {
return gids, nil
}
-func (p *Process) GroupsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) GroupsWithContext(_ context.Context) ([]uint32, error) {
k, err := p.getKProc()
if err != nil {
return nil, err
@@ -217,7 +217,7 @@ func (p *Process) GroupsWithContext(ctx context.Context) ([]uint32, error) {
return groups, nil
}
-func (p *Process) TerminalWithContext(ctx context.Context) (string, error) {
+func (p *Process) TerminalWithContext(_ context.Context) (string, error) {
k, err := p.getKProc()
if err != nil {
return "", err
@@ -233,7 +233,7 @@ func (p *Process) TerminalWithContext(ctx context.Context) (string, error) {
return termmap[ttyNr], nil
}
-func (p *Process) NiceWithContext(ctx context.Context) (int32, error) {
+func (p *Process) NiceWithContext(_ context.Context) (int32, error) {
k, err := p.getKProc()
if err != nil {
return 0, err
@@ -241,7 +241,7 @@ func (p *Process) NiceWithContext(ctx context.Context) (int32, error) {
return int32(k.Nice), nil
}
-func (p *Process) IOCountersWithContext(ctx context.Context) (*IOCountersStat, error) {
+func (p *Process) IOCountersWithContext(_ context.Context) (*IOCountersStat, error) {
k, err := p.getKProc()
if err != nil {
return nil, err
@@ -252,12 +252,12 @@ func (p *Process) IOCountersWithContext(ctx context.Context) (*IOCountersStat, e
}, nil
}
-func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) {
+func (p *Process) NumThreadsWithContext(_ context.Context) (int32, error) {
/* not supported, just return 1 */
return 1, nil
}
-func (p *Process) TimesWithContext(ctx context.Context) (*cpu.TimesStat, error) {
+func (p *Process) TimesWithContext(_ context.Context) (*cpu.TimesStat, error) {
k, err := p.getKProc()
if err != nil {
return nil, err
@@ -305,11 +305,11 @@ func (p *Process) ChildrenWithContext(ctx context.Context) ([]*Process, error) {
return ret, nil
}
-func (p *Process) ConnectionsWithContext(ctx context.Context) ([]net.ConnectionStat, error) {
+func (p *Process) ConnectionsWithContext(_ context.Context) ([]net.ConnectionStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) ConnectionsMaxWithContext(ctx context.Context, maxConn int) ([]net.ConnectionStat, error) {
+func (p *Process) ConnectionsMaxWithContext(_ context.Context, _ int) ([]net.ConnectionStat, error) {
return nil, common.ErrNotImplementedError
}
diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_plan9.go b/vendor/github.com/shirou/gopsutil/v4/process/process_plan9.go
index c82e54a..7f68771 100644
--- a/vendor/github.com/shirou/gopsutil/v4/process/process_plan9.go
+++ b/vendor/github.com/shirou/gopsutil/v4/process/process_plan9.go
@@ -30,174 +30,174 @@ type MemoryMapsStat struct {
type MemoryInfoExStat struct{}
-func pidsWithContext(ctx context.Context) ([]int32, error) {
+func pidsWithContext(_ context.Context) ([]int32, error) {
return nil, common.ErrNotImplementedError
}
-func ProcessesWithContext(ctx context.Context) ([]*Process, error) {
+func ProcessesWithContext(_ context.Context) ([]*Process, error) {
return nil, common.ErrNotImplementedError
}
-func PidExistsWithContext(ctx context.Context, pid int32) (bool, error) {
+func PidExistsWithContext(_ context.Context, _ int32) (bool, error) {
return false, common.ErrNotImplementedError
}
-func (p *Process) PpidWithContext(ctx context.Context) (int32, error) {
+func (p *Process) PpidWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) NameWithContext(ctx context.Context) (string, error) {
+func (p *Process) NameWithContext(_ context.Context) (string, error) {
return "", common.ErrNotImplementedError
}
-func (p *Process) TgidWithContext(ctx context.Context) (int32, error) {
+func (p *Process) TgidWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) ExeWithContext(ctx context.Context) (string, error) {
+func (p *Process) ExeWithContext(_ context.Context) (string, error) {
return "", common.ErrNotImplementedError
}
-func (p *Process) CmdlineWithContext(ctx context.Context) (string, error) {
+func (p *Process) CmdlineWithContext(_ context.Context) (string, error) {
return "", common.ErrNotImplementedError
}
-func (p *Process) CmdlineSliceWithContext(ctx context.Context) ([]string, error) {
+func (p *Process) CmdlineSliceWithContext(_ context.Context) ([]string, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) createTimeWithContext(ctx context.Context) (int64, error) {
+func (p *Process) createTimeWithContext(_ context.Context) (int64, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) CwdWithContext(ctx context.Context) (string, error) {
+func (p *Process) CwdWithContext(_ context.Context) (string, error) {
return "", common.ErrNotImplementedError
}
-func (p *Process) StatusWithContext(ctx context.Context) ([]string, error) {
+func (p *Process) StatusWithContext(_ context.Context) ([]string, error) {
return []string{""}, common.ErrNotImplementedError
}
-func (p *Process) ForegroundWithContext(ctx context.Context) (bool, error) {
+func (p *Process) ForegroundWithContext(_ context.Context) (bool, error) {
return false, common.ErrNotImplementedError
}
-func (p *Process) UidsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) UidsWithContext(_ context.Context) ([]uint32, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) GidsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) GidsWithContext(_ context.Context) ([]uint32, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) GroupsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) GroupsWithContext(_ context.Context) ([]uint32, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) TerminalWithContext(ctx context.Context) (string, error) {
+func (p *Process) TerminalWithContext(_ context.Context) (string, error) {
return "", common.ErrNotImplementedError
}
-func (p *Process) NiceWithContext(ctx context.Context) (int32, error) {
+func (p *Process) NiceWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) IOniceWithContext(ctx context.Context) (int32, error) {
+func (p *Process) IOniceWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) RlimitWithContext(ctx context.Context) ([]RlimitStat, error) {
+func (p *Process) RlimitWithContext(_ context.Context) ([]RlimitStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) RlimitUsageWithContext(ctx context.Context, gatherUsed bool) ([]RlimitStat, error) {
+func (p *Process) RlimitUsageWithContext(_ context.Context, _ bool) ([]RlimitStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) IOCountersWithContext(ctx context.Context) (*IOCountersStat, error) {
+func (p *Process) IOCountersWithContext(_ context.Context) (*IOCountersStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) NumCtxSwitchesWithContext(ctx context.Context) (*NumCtxSwitchesStat, error) {
+func (p *Process) NumCtxSwitchesWithContext(_ context.Context) (*NumCtxSwitchesStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) NumFDsWithContext(ctx context.Context) (int32, error) {
+func (p *Process) NumFDsWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) {
+func (p *Process) NumThreadsWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) ThreadsWithContext(ctx context.Context) (map[int32]*cpu.TimesStat, error) {
+func (p *Process) ThreadsWithContext(_ context.Context) (map[int32]*cpu.TimesStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) TimesWithContext(ctx context.Context) (*cpu.TimesStat, error) {
+func (p *Process) TimesWithContext(_ context.Context) (*cpu.TimesStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) CPUAffinityWithContext(ctx context.Context) ([]int32, error) {
+func (p *Process) CPUAffinityWithContext(_ context.Context) ([]int32, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, error) {
+func (p *Process) MemoryInfoWithContext(_ context.Context) (*MemoryInfoStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) MemoryInfoExWithContext(ctx context.Context) (*MemoryInfoExStat, error) {
+func (p *Process) MemoryInfoExWithContext(_ context.Context) (*MemoryInfoExStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) PageFaultsWithContext(ctx context.Context) (*PageFaultsStat, error) {
+func (p *Process) PageFaultsWithContext(_ context.Context) (*PageFaultsStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) ChildrenWithContext(ctx context.Context) ([]*Process, error) {
+func (p *Process) ChildrenWithContext(_ context.Context) ([]*Process, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) OpenFilesWithContext(ctx context.Context) ([]OpenFilesStat, error) {
+func (p *Process) OpenFilesWithContext(_ context.Context) ([]OpenFilesStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) ConnectionsWithContext(ctx context.Context) ([]net.ConnectionStat, error) {
+func (p *Process) ConnectionsWithContext(_ context.Context) ([]net.ConnectionStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) ConnectionsMaxWithContext(ctx context.Context, maxConn int) ([]net.ConnectionStat, error) {
+func (p *Process) ConnectionsMaxWithContext(_ context.Context, _ int) ([]net.ConnectionStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) MemoryMapsWithContext(ctx context.Context, grouped bool) (*[]MemoryMapsStat, error) {
+func (p *Process) MemoryMapsWithContext(_ context.Context, _ bool) (*[]MemoryMapsStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) SendSignalWithContext(ctx context.Context, sig Signal) error {
+func (p *Process) SendSignalWithContext(_ context.Context, _ Signal) error {
return common.ErrNotImplementedError
}
-func (p *Process) SuspendWithContext(ctx context.Context) error {
+func (p *Process) SuspendWithContext(_ context.Context) error {
return common.ErrNotImplementedError
}
-func (p *Process) ResumeWithContext(ctx context.Context) error {
+func (p *Process) ResumeWithContext(_ context.Context) error {
return common.ErrNotImplementedError
}
-func (p *Process) TerminateWithContext(ctx context.Context) error {
+func (p *Process) TerminateWithContext(_ context.Context) error {
return common.ErrNotImplementedError
}
-func (p *Process) KillWithContext(ctx context.Context) error {
+func (p *Process) KillWithContext(_ context.Context) error {
return common.ErrNotImplementedError
}
-func (p *Process) UsernameWithContext(ctx context.Context) (string, error) {
+func (p *Process) UsernameWithContext(_ context.Context) (string, error) {
return "", common.ErrNotImplementedError
}
-func (p *Process) EnvironWithContext(ctx context.Context) ([]string, error) {
+func (p *Process) EnvironWithContext(_ context.Context) ([]string, error) {
return nil, common.ErrNotImplementedError
}
diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_posix.go b/vendor/github.com/shirou/gopsutil/v4/process/process_posix.go
index 96c5e06..12d5fe2 100644
--- a/vendor/github.com/shirou/gopsutil/v4/process/process_posix.go
+++ b/vendor/github.com/shirou/gopsutil/v4/process/process_posix.go
@@ -71,7 +71,7 @@ func getTerminalMap() (map[uint64]string, error) {
return nil, err
}
rdev := uint64(stat.Rdev)
- ret[rdev] = strings.Replace(name, "/dev", "", -1)
+ ret[rdev] = strings.ReplaceAll(name, "/dev", "")
}
return ret, nil
}
@@ -140,7 +140,7 @@ func PidExistsWithContext(ctx context.Context, pid int32) (bool, error) {
return false, err
}
-func (p *Process) SendSignalWithContext(ctx context.Context, sig syscall.Signal) error {
+func (p *Process) SendSignalWithContext(_ context.Context, sig syscall.Signal) error {
process, err := os.FindProcess(int(p.Pid))
if err != nil {
return err
diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_solaris.go b/vendor/github.com/shirou/gopsutil/v4/process/process_solaris.go
index 5c8d4d3..6af5633 100644
--- a/vendor/github.com/shirou/gopsutil/v4/process/process_solaris.go
+++ b/vendor/github.com/shirou/gopsutil/v4/process/process_solaris.go
@@ -52,15 +52,15 @@ func ProcessesWithContext(ctx context.Context) ([]*Process, error) {
return out, nil
}
-func (p *Process) PpidWithContext(ctx context.Context) (int32, error) {
+func (p *Process) PpidWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) NameWithContext(ctx context.Context) (string, error) {
+func (p *Process) NameWithContext(_ context.Context) (string, error) {
return "", common.ErrNotImplementedError
}
-func (p *Process) TgidWithContext(ctx context.Context) (int32, error) {
+func (p *Process) TgidWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
@@ -80,7 +80,7 @@ func (p *Process) CmdlineSliceWithContext(ctx context.Context) ([]string, error)
return p.fillSliceFromCmdlineWithContext(ctx)
}
-func (p *Process) createTimeWithContext(ctx context.Context) (int64, error) {
+func (p *Process) createTimeWithContext(_ context.Context) (int64, error) {
return 0, common.ErrNotImplementedError
}
@@ -88,51 +88,51 @@ func (p *Process) CwdWithContext(ctx context.Context) (string, error) {
return p.fillFromPathCwdWithContext(ctx)
}
-func (p *Process) StatusWithContext(ctx context.Context) ([]string, error) {
+func (p *Process) StatusWithContext(_ context.Context) ([]string, error) {
return []string{""}, common.ErrNotImplementedError
}
-func (p *Process) ForegroundWithContext(ctx context.Context) (bool, error) {
+func (p *Process) ForegroundWithContext(_ context.Context) (bool, error) {
return false, common.ErrNotImplementedError
}
-func (p *Process) UidsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) UidsWithContext(_ context.Context) ([]uint32, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) GidsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) GidsWithContext(_ context.Context) ([]uint32, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) GroupsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) GroupsWithContext(_ context.Context) ([]uint32, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) TerminalWithContext(ctx context.Context) (string, error) {
+func (p *Process) TerminalWithContext(_ context.Context) (string, error) {
return "", common.ErrNotImplementedError
}
-func (p *Process) NiceWithContext(ctx context.Context) (int32, error) {
+func (p *Process) NiceWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) IOniceWithContext(ctx context.Context) (int32, error) {
+func (p *Process) IOniceWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) RlimitWithContext(ctx context.Context) ([]RlimitStat, error) {
+func (p *Process) RlimitWithContext(_ context.Context) ([]RlimitStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) RlimitUsageWithContext(ctx context.Context, gatherUsed bool) ([]RlimitStat, error) {
+func (p *Process) RlimitUsageWithContext(_ context.Context, _ bool) ([]RlimitStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) IOCountersWithContext(ctx context.Context) (*IOCountersStat, error) {
+func (p *Process) IOCountersWithContext(_ context.Context) (*IOCountersStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) NumCtxSwitchesWithContext(ctx context.Context) (*NumCtxSwitchesStat, error) {
+func (p *Process) NumCtxSwitchesWithContext(_ context.Context) (*NumCtxSwitchesStat, error) {
return nil, common.ErrNotImplementedError
}
@@ -141,55 +141,55 @@ func (p *Process) NumFDsWithContext(ctx context.Context) (int32, error) {
return int32(len(fnames)), err
}
-func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) {
+func (p *Process) NumThreadsWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) ThreadsWithContext(ctx context.Context) (map[int32]*cpu.TimesStat, error) {
+func (p *Process) ThreadsWithContext(_ context.Context) (map[int32]*cpu.TimesStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) TimesWithContext(ctx context.Context) (*cpu.TimesStat, error) {
+func (p *Process) TimesWithContext(_ context.Context) (*cpu.TimesStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) CPUAffinityWithContext(ctx context.Context) ([]int32, error) {
+func (p *Process) CPUAffinityWithContext(_ context.Context) ([]int32, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, error) {
+func (p *Process) MemoryInfoWithContext(_ context.Context) (*MemoryInfoStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) MemoryInfoExWithContext(ctx context.Context) (*MemoryInfoExStat, error) {
+func (p *Process) MemoryInfoExWithContext(_ context.Context) (*MemoryInfoExStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) PageFaultsWithContext(ctx context.Context) (*PageFaultsStat, error) {
+func (p *Process) PageFaultsWithContext(_ context.Context) (*PageFaultsStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) ChildrenWithContext(ctx context.Context) ([]*Process, error) {
+func (p *Process) ChildrenWithContext(_ context.Context) ([]*Process, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) OpenFilesWithContext(ctx context.Context) ([]OpenFilesStat, error) {
+func (p *Process) OpenFilesWithContext(_ context.Context) ([]OpenFilesStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) ConnectionsWithContext(ctx context.Context) ([]net.ConnectionStat, error) {
+func (p *Process) ConnectionsWithContext(_ context.Context) ([]net.ConnectionStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) ConnectionsMaxWithContext(ctx context.Context, maxConn int) ([]net.ConnectionStat, error) {
+func (p *Process) ConnectionsMaxWithContext(_ context.Context, _ int) ([]net.ConnectionStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) MemoryMapsWithContext(ctx context.Context, grouped bool) (*[]MemoryMapsStat, error) {
+func (p *Process) MemoryMapsWithContext(_ context.Context, _ bool) (*[]MemoryMapsStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) EnvironWithContext(ctx context.Context) ([]string, error) {
+func (p *Process) EnvironWithContext(_ context.Context) ([]string, error) {
return nil, common.ErrNotImplementedError
}
@@ -247,10 +247,7 @@ func (p *Process) fillFromCmdlineWithContext(ctx context.Context) (string, error
return "", err
}
ret := strings.FieldsFunc(string(cmdline), func(r rune) bool {
- if r == '\u0000' {
- return true
- }
- return false
+ return r == '\u0000'
})
return strings.Join(ret, " "), nil
diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_windows.go b/vendor/github.com/shirou/gopsutil/v4/process/process_windows.go
index 012886d..c6069a5 100644
--- a/vendor/github.com/shirou/gopsutil/v4/process/process_windows.go
+++ b/vendor/github.com/shirou/gopsutil/v4/process/process_windows.go
@@ -12,16 +12,16 @@ import (
"os"
"path/filepath"
"reflect"
- "strings"
"syscall"
"time"
"unicode/utf16"
"unsafe"
+ "golang.org/x/sys/windows"
+
"github.com/shirou/gopsutil/v4/cpu"
"github.com/shirou/gopsutil/v4/internal/common"
"github.com/shirou/gopsutil/v4/net"
- "golang.org/x/sys/windows"
)
type Signal = syscall.Signal
@@ -241,11 +241,11 @@ func init() {
0)
}
-func pidsWithContext(ctx context.Context) ([]int32, error) {
+func pidsWithContext(_ context.Context) ([]int32, error) {
// inspired by https://gist.github.com/henkman/3083408
// and https://github.com/giampaolo/psutil/blob/1c3a15f637521ba5c0031283da39c733fda53e4c/psutil/arch/windows/process_info.c#L315-L329
var ret []int32
- var read uint32 = 0
+ var read uint32
var psSize uint32 = 1024
const dwordSize uint32 = 4
@@ -288,10 +288,10 @@ func PidExistsWithContext(ctx context.Context, pid int32) (bool, error) {
return false, err
}
h, err := windows.OpenProcess(windows.SYNCHRONIZE, false, uint32(pid))
- if err == windows.ERROR_ACCESS_DENIED {
+ if errors.Is(err, windows.ERROR_ACCESS_DENIED) {
return true, nil
}
- if err == windows.ERROR_INVALID_PARAMETER {
+ if errors.Is(err, windows.ERROR_INVALID_PARAMETER) {
return false, nil
}
if err != nil {
@@ -302,7 +302,7 @@ func PidExistsWithContext(ctx context.Context, pid int32) (bool, error) {
return event == uint32(windows.WAIT_TIMEOUT), err
}
-func (p *Process) PpidWithContext(ctx context.Context) (int32, error) {
+func (p *Process) PpidWithContext(_ context.Context) (int32, error) {
// if cached already, return from cache
cachedPpid := p.getPpid()
if cachedPpid != 0 {
@@ -330,17 +330,17 @@ func (p *Process) NameWithContext(ctx context.Context) (string, error) {
exe, err := p.ExeWithContext(ctx)
if err != nil {
- return "", fmt.Errorf("could not get Name: %s", err)
+ return "", fmt.Errorf("could not get Name: %w", err)
}
return filepath.Base(exe), nil
}
-func (p *Process) TgidWithContext(ctx context.Context) (int32, error) {
+func (p *Process) TgidWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) ExeWithContext(ctx context.Context) (string, error) {
+func (p *Process) ExeWithContext(_ context.Context) (string, error) {
c, err := windows.OpenProcess(processQueryInformation, false, uint32(p.Pid))
if err != nil {
return "", err
@@ -357,20 +357,20 @@ func (p *Process) ExeWithContext(ctx context.Context) (string, error) {
if ret == 0 {
return "", err
}
- return windows.UTF16ToString(buf[:]), nil
+ return windows.UTF16ToString(buf), nil
}
// XP fallback
ret, _, err := procGetProcessImageFileNameW.Call(uintptr(c), uintptr(unsafe.Pointer(&buf[0])), uintptr(size))
if ret == 0 {
return "", err
}
- return common.ConvertDOSPath(windows.UTF16ToString(buf[:])), nil
+ return common.ConvertDOSPath(windows.UTF16ToString(buf)), nil
}
func (p *Process) CmdlineWithContext(_ context.Context) (string, error) {
cmdline, err := getProcessCommandLine(p.Pid)
if err != nil {
- return "", fmt.Errorf("could not get CommandLine: %s", err)
+ return "", fmt.Errorf("could not get CommandLine: %w", err)
}
return cmdline, nil
}
@@ -380,13 +380,33 @@ func (p *Process) CmdlineSliceWithContext(ctx context.Context) ([]string, error)
if err != nil {
return nil, err
}
- return strings.Split(cmdline, " "), nil
+ return parseCmdline(cmdline)
}
-func (p *Process) createTimeWithContext(ctx context.Context) (int64, error) {
+func parseCmdline(cmdline string) ([]string, error) {
+ cmdlineptr, err := windows.UTF16PtrFromString(cmdline)
+ if err != nil {
+ return nil, err
+ }
+
+ var argc int32
+ argvptr, err := windows.CommandLineToArgv(cmdlineptr, &argc)
+ if err != nil {
+ return nil, err
+ }
+ defer windows.LocalFree(windows.Handle(uintptr(unsafe.Pointer(argvptr))))
+
+ argv := make([]string, argc)
+ for i, v := range (*argvptr)[:argc] {
+ argv[i] = windows.UTF16ToString((*v)[:])
+ }
+ return argv, nil
+}
+
+func (p *Process) createTimeWithContext(_ context.Context) (int64, error) {
ru, err := getRusage(p.Pid)
if err != nil {
- return 0, fmt.Errorf("could not get CreationDate: %s", err)
+ return 0, fmt.Errorf("could not get CreationDate: %w", err)
}
return ru.CreationTime.Nanoseconds() / 1000000, nil
@@ -394,7 +414,7 @@ func (p *Process) createTimeWithContext(ctx context.Context) (int64, error) {
func (p *Process) CwdWithContext(_ context.Context) (string, error) {
h, err := windows.OpenProcess(processQueryInformation|windows.PROCESS_VM_READ, false, uint32(p.Pid))
- if err == windows.ERROR_ACCESS_DENIED || err == windows.ERROR_INVALID_PARAMETER {
+ if errors.Is(err, windows.ERROR_ACCESS_DENIED) || errors.Is(err, windows.ERROR_INVALID_PARAMETER) {
return "", nil
}
if err != nil {
@@ -436,15 +456,15 @@ func (p *Process) CwdWithContext(_ context.Context) (string, error) {
return "", nil
}
-func (p *Process) StatusWithContext(ctx context.Context) ([]string, error) {
+func (p *Process) StatusWithContext(_ context.Context) ([]string, error) {
return []string{""}, common.ErrNotImplementedError
}
-func (p *Process) ForegroundWithContext(ctx context.Context) (bool, error) {
+func (p *Process) ForegroundWithContext(_ context.Context) (bool, error) {
return false, common.ErrNotImplementedError
}
-func (p *Process) UsernameWithContext(ctx context.Context) (string, error) {
+func (p *Process) UsernameWithContext(_ context.Context) (string, error) {
pid := p.Pid
c, err := windows.OpenProcess(processQueryInformation, false, uint32(pid))
if err != nil {
@@ -467,19 +487,19 @@ func (p *Process) UsernameWithContext(ctx context.Context) (string, error) {
return domain + "\\" + user, err
}
-func (p *Process) UidsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) UidsWithContext(_ context.Context) ([]uint32, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) GidsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) GidsWithContext(_ context.Context) ([]uint32, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) GroupsWithContext(ctx context.Context) ([]uint32, error) {
+func (p *Process) GroupsWithContext(_ context.Context) ([]uint32, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) TerminalWithContext(ctx context.Context) (string, error) {
+func (p *Process) TerminalWithContext(_ context.Context) (string, error) {
return "", common.ErrNotImplementedError
}
@@ -495,7 +515,7 @@ var priorityClasses = map[int]int32{
0x00000100: 24, // REALTIME_PRIORITY_CLASS
}
-func (p *Process) NiceWithContext(ctx context.Context) (int32, error) {
+func (p *Process) NiceWithContext(_ context.Context) (int32, error) {
c, err := windows.OpenProcess(processQueryInformation, false, uint32(p.Pid))
if err != nil {
return 0, err
@@ -512,19 +532,19 @@ func (p *Process) NiceWithContext(ctx context.Context) (int32, error) {
return priority, nil
}
-func (p *Process) IOniceWithContext(ctx context.Context) (int32, error) {
+func (p *Process) IOniceWithContext(_ context.Context) (int32, error) {
return 0, common.ErrNotImplementedError
}
-func (p *Process) RlimitWithContext(ctx context.Context) ([]RlimitStat, error) {
+func (p *Process) RlimitWithContext(_ context.Context) ([]RlimitStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) RlimitUsageWithContext(ctx context.Context, gatherUsed bool) ([]RlimitStat, error) {
+func (p *Process) RlimitUsageWithContext(_ context.Context, _ bool) ([]RlimitStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) IOCountersWithContext(ctx context.Context) (*IOCountersStat, error) {
+func (p *Process) IOCountersWithContext(_ context.Context) (*IOCountersStat, error) {
c, err := windows.OpenProcess(processQueryInformation, false, uint32(p.Pid))
if err != nil {
return nil, err
@@ -545,13 +565,13 @@ func (p *Process) IOCountersWithContext(ctx context.Context) (*IOCountersStat, e
return stats, nil
}
-func (p *Process) NumCtxSwitchesWithContext(ctx context.Context) (*NumCtxSwitchesStat, error) {
+func (p *Process) NumCtxSwitchesWithContext(_ context.Context) (*NumCtxSwitchesStat, error) {
return nil, common.ErrNotImplementedError
}
// NumFDsWithContext returns the number of handles for a process on Windows,
// not the number of file descriptors (FDs).
-func (p *Process) NumFDsWithContext(ctx context.Context) (int32, error) {
+func (p *Process) NumFDsWithContext(_ context.Context) (int32, error) {
handle, err := windows.OpenProcess(processQueryInformation, false, uint32(p.Pid))
if err != nil {
return 0, err
@@ -566,7 +586,7 @@ func (p *Process) NumFDsWithContext(ctx context.Context) (int32, error) {
return int32(handleCount), nil
}
-func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) {
+func (p *Process) NumThreadsWithContext(_ context.Context) (int32, error) {
ppid, ret, _, err := getFromSnapProcess(p.Pid)
if err != nil {
return 0, err
@@ -581,11 +601,11 @@ func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) {
return ret, nil
}
-func (p *Process) ThreadsWithContext(ctx context.Context) (map[int32]*cpu.TimesStat, error) {
+func (p *Process) ThreadsWithContext(_ context.Context) (map[int32]*cpu.TimesStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) TimesWithContext(ctx context.Context) (*cpu.TimesStat, error) {
+func (p *Process) TimesWithContext(_ context.Context) (*cpu.TimesStat, error) {
sysTimes, err := getProcessCPUTimes(p.Pid)
if err != nil {
return nil, err
@@ -609,11 +629,11 @@ func (p *Process) TimesWithContext(ctx context.Context) (*cpu.TimesStat, error)
}, nil
}
-func (p *Process) CPUAffinityWithContext(ctx context.Context) ([]int32, error) {
+func (p *Process) CPUAffinityWithContext(_ context.Context) ([]int32, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, error) {
+func (p *Process) MemoryInfoWithContext(_ context.Context) (*MemoryInfoStat, error) {
mem, err := getMemoryInfo(p.Pid)
if err != nil {
return nil, err
@@ -627,12 +647,22 @@ func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, e
return ret, nil
}
-func (p *Process) MemoryInfoExWithContext(ctx context.Context) (*MemoryInfoExStat, error) {
+func (p *Process) MemoryInfoExWithContext(_ context.Context) (*MemoryInfoExStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) PageFaultsWithContext(ctx context.Context) (*PageFaultsStat, error) {
- return nil, common.ErrNotImplementedError
+func (p *Process) PageFaultsWithContext(_ context.Context) (*PageFaultsStat, error) {
+ mem, err := getMemoryInfo(p.Pid)
+ if err != nil {
+ return nil, err
+ }
+
+ ret := &PageFaultsStat{
+ // Since Windows does not distinguish between Major and Minor faults, all faults are treated as Major
+ MajorFaults: uint64(mem.PageFaultCount),
+ }
+
+ return ret, nil
}
func (p *Process) ChildrenWithContext(ctx context.Context) ([]*Process, error) {
@@ -758,19 +788,19 @@ func (p *Process) ConnectionsWithContext(ctx context.Context) ([]net.ConnectionS
return net.ConnectionsPidWithContext(ctx, "all", p.Pid)
}
-func (p *Process) ConnectionsMaxWithContext(ctx context.Context, maxConn int) ([]net.ConnectionStat, error) {
+func (p *Process) ConnectionsMaxWithContext(_ context.Context, _ int) ([]net.ConnectionStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) MemoryMapsWithContext(ctx context.Context, grouped bool) (*[]MemoryMapsStat, error) {
+func (p *Process) MemoryMapsWithContext(_ context.Context, _ bool) (*[]MemoryMapsStat, error) {
return nil, common.ErrNotImplementedError
}
-func (p *Process) SendSignalWithContext(ctx context.Context, sig syscall.Signal) error {
+func (p *Process) SendSignalWithContext(_ context.Context, _ syscall.Signal) error {
return common.ErrNotImplementedError
}
-func (p *Process) SuspendWithContext(ctx context.Context) error {
+func (p *Process) SuspendWithContext(_ context.Context) error {
c, err := windows.OpenProcess(windows.PROCESS_SUSPEND_RESUME, false, uint32(p.Pid))
if err != nil {
return err
@@ -786,7 +816,7 @@ func (p *Process) SuspendWithContext(ctx context.Context) error {
return nil
}
-func (p *Process) ResumeWithContext(ctx context.Context) error {
+func (p *Process) ResumeWithContext(_ context.Context) error {
c, err := windows.OpenProcess(windows.PROCESS_SUSPEND_RESUME, false, uint32(p.Pid))
if err != nil {
return err
@@ -802,7 +832,7 @@ func (p *Process) ResumeWithContext(ctx context.Context) error {
return nil
}
-func (p *Process) TerminateWithContext(ctx context.Context) error {
+func (p *Process) TerminateWithContext(_ context.Context) error {
proc, err := windows.OpenProcess(windows.PROCESS_TERMINATE, false, uint32(p.Pid))
if err != nil {
return err
@@ -812,7 +842,7 @@ func (p *Process) TerminateWithContext(ctx context.Context) error {
return err
}
-func (p *Process) KillWithContext(ctx context.Context) error {
+func (p *Process) KillWithContext(_ context.Context) error {
process, err := os.FindProcess(int(p.Pid))
if err != nil {
return err
@@ -822,9 +852,9 @@ func (p *Process) KillWithContext(ctx context.Context) error {
}
func (p *Process) EnvironWithContext(ctx context.Context) ([]string, error) {
- envVars, err := getProcessEnvironmentVariables(p.Pid, ctx)
+ envVars, err := getProcessEnvironmentVariables(ctx, p.Pid)
if err != nil {
- return nil, fmt.Errorf("could not get environment variables: %s", err)
+ return nil, fmt.Errorf("could not get environment variables: %w", err)
}
return envVars, nil
}
@@ -844,7 +874,7 @@ func (p *Process) setPpid(ppid int32) {
p.parent = ppid
}
-func getFromSnapProcess(pid int32) (int32, int32, string, error) {
+func getFromSnapProcess(pid int32) (int32, int32, string, error) { //nolint:unparam //FIXME
snap, err := windows.CreateToolhelp32Snapshot(windows.TH32CS_SNAPPROCESS, uint32(pid))
if err != nil {
return 0, 0, "", err
@@ -872,7 +902,7 @@ func ProcessesWithContext(ctx context.Context) ([]*Process, error) {
pids, err := PidsWithContext(ctx)
if err != nil {
- return out, fmt.Errorf("could not get Processes %s", err)
+ return out, fmt.Errorf("could not get Processes %w", err)
}
for _, pid := range pids {
@@ -928,7 +958,7 @@ func getProcessMemoryInfo(h windows.Handle, mem *PROCESS_MEMORY_COUNTERS) (err e
return
}
-type SYSTEM_TIMES struct {
+type SYSTEM_TIMES struct { //nolint:revive //FIXME
CreateTime syscall.Filetime
ExitTime syscall.Filetime
KernelTime syscall.Filetime
@@ -963,13 +993,13 @@ func getUserProcessParams32(handle windows.Handle) (rtlUserProcessParameters32,
buf := readProcessMemory(syscall.Handle(handle), true, pebAddress, uint(unsafe.Sizeof(processEnvironmentBlock32{})))
if len(buf) != int(unsafe.Sizeof(processEnvironmentBlock32{})) {
- return rtlUserProcessParameters32{}, fmt.Errorf("cannot read process PEB")
+ return rtlUserProcessParameters32{}, errors.New("cannot read process PEB")
}
peb := (*processEnvironmentBlock32)(unsafe.Pointer(&buf[0]))
userProcessAddress := uint64(peb.ProcessParameters)
buf = readProcessMemory(syscall.Handle(handle), true, userProcessAddress, uint(unsafe.Sizeof(rtlUserProcessParameters32{})))
if len(buf) != int(unsafe.Sizeof(rtlUserProcessParameters32{})) {
- return rtlUserProcessParameters32{}, fmt.Errorf("cannot read user process parameters")
+ return rtlUserProcessParameters32{}, errors.New("cannot read user process parameters")
}
return *(*rtlUserProcessParameters32)(unsafe.Pointer(&buf[0])), nil
}
@@ -982,13 +1012,13 @@ func getUserProcessParams64(handle windows.Handle) (rtlUserProcessParameters64,
buf := readProcessMemory(syscall.Handle(handle), false, pebAddress, uint(unsafe.Sizeof(processEnvironmentBlock64{})))
if len(buf) != int(unsafe.Sizeof(processEnvironmentBlock64{})) {
- return rtlUserProcessParameters64{}, fmt.Errorf("cannot read process PEB")
+ return rtlUserProcessParameters64{}, errors.New("cannot read process PEB")
}
peb := (*processEnvironmentBlock64)(unsafe.Pointer(&buf[0]))
userProcessAddress := peb.ProcessParameters
buf = readProcessMemory(syscall.Handle(handle), false, userProcessAddress, uint(unsafe.Sizeof(rtlUserProcessParameters64{})))
if len(buf) != int(unsafe.Sizeof(rtlUserProcessParameters64{})) {
- return rtlUserProcessParameters64{}, fmt.Errorf("cannot read user process parameters")
+ return rtlUserProcessParameters64{}, errors.New("cannot read user process parameters")
}
return *(*rtlUserProcessParameters64)(unsafe.Pointer(&buf[0])), nil
}
@@ -1038,9 +1068,9 @@ func is32BitProcess(h windows.Handle) bool {
return procIs32Bits
}
-func getProcessEnvironmentVariables(pid int32, ctx context.Context) ([]string, error) {
+func getProcessEnvironmentVariables(ctx context.Context, pid int32) ([]string, error) {
h, err := windows.OpenProcess(processQueryInformation|windows.PROCESS_VM_READ, false, uint32(pid))
- if err == windows.ERROR_ACCESS_DENIED || err == windows.ERROR_INVALID_PARAMETER {
+ if errors.Is(err, windows.ERROR_ACCESS_DENIED) || errors.Is(err, windows.ERROR_INVALID_PARAMETER) {
return nil, nil
}
if err != nil {
@@ -1124,7 +1154,7 @@ func (p *processReader) Read(buf []byte) (int, error) {
func getProcessCommandLine(pid int32) (string, error) {
h, err := windows.OpenProcess(processQueryInformation|windows.PROCESS_VM_READ, false, uint32(pid))
- if err == windows.ERROR_ACCESS_DENIED || err == windows.ERROR_INVALID_PARAMETER {
+ if errors.Is(err, windows.ERROR_ACCESS_DENIED) || errors.Is(err, windows.ERROR_INVALID_PARAMETER) {
return "", nil
}
if err != nil {
diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_windows_32bit.go b/vendor/github.com/shirou/gopsutil/v4/process/process_windows_32bit.go
index 2b231c7..911351b 100644
--- a/vendor/github.com/shirou/gopsutil/v4/process/process_windows_32bit.go
+++ b/vendor/github.com/shirou/gopsutil/v4/process/process_windows_32bit.go
@@ -8,11 +8,12 @@ import (
"syscall"
"unsafe"
- "github.com/shirou/gopsutil/v4/internal/common"
"golang.org/x/sys/windows"
+
+ "github.com/shirou/gopsutil/v4/internal/common"
)
-type PROCESS_MEMORY_COUNTERS struct {
+type PROCESS_MEMORY_COUNTERS struct { //nolint:revive //FIXME
CB uint32
PageFaultCount uint32
PeakWorkingSetSize uint32
@@ -39,30 +40,27 @@ func queryPebAddress(procHandle syscall.Handle, is32BitProcess bool) (uint64, er
)
if status := windows.NTStatus(ret); status == windows.STATUS_SUCCESS {
return uint64(info.PebBaseAddress), nil
- } else {
- return 0, windows.NTStatus(ret)
}
- } else {
- // we are on a 32-bit process reading an external 64-bit process
- if common.ProcNtWow64QueryInformationProcess64.Find() == nil { // avoid panic
- var info processBasicInformation64
+ return 0, windows.NTStatus(ret)
+ }
+ // we are on a 32-bit process reading an external 64-bit process
+ if common.ProcNtWow64QueryInformationProcess64.Find() != nil {
+ return 0, errors.New("can't find API to query 64 bit process from 32 bit")
+ }
+ // avoid panic
+ var info processBasicInformation64
- ret, _, _ := common.ProcNtWow64QueryInformationProcess64.Call(
- uintptr(procHandle),
- uintptr(common.ProcessBasicInformation),
- uintptr(unsafe.Pointer(&info)),
- uintptr(unsafe.Sizeof(info)),
- uintptr(0),
- )
- if status := windows.NTStatus(ret); status == windows.STATUS_SUCCESS {
- return info.PebBaseAddress, nil
- } else {
- return 0, windows.NTStatus(ret)
- }
- } else {
- return 0, errors.New("can't find API to query 64 bit process from 32 bit")
- }
+ ret, _, _ := common.ProcNtWow64QueryInformationProcess64.Call(
+ uintptr(procHandle),
+ uintptr(common.ProcessBasicInformation),
+ uintptr(unsafe.Pointer(&info)),
+ uintptr(unsafe.Sizeof(info)),
+ uintptr(0),
+ )
+ if status := windows.NTStatus(ret); status == windows.STATUS_SUCCESS {
+ return info.PebBaseAddress, nil
}
+ return 0, windows.NTStatus(ret)
}
func readProcessMemory(h syscall.Handle, is32BitProcess bool, address uint64, size uint) []byte {
@@ -81,25 +79,23 @@ func readProcessMemory(h syscall.Handle, is32BitProcess bool, address uint64, si
if int(ret) >= 0 && read > 0 {
return buffer[:read]
}
- } else {
// reading a 64-bit process from a 32-bit one
- if common.ProcNtWow64ReadVirtualMemory64.Find() == nil { // avoid panic
- var read uint64
+ } else if common.ProcNtWow64ReadVirtualMemory64.Find() == nil { // avoid panic
+ var read uint64
- buffer := make([]byte, size)
+ buffer := make([]byte, size)
- ret, _, _ := common.ProcNtWow64ReadVirtualMemory64.Call(
- uintptr(h),
- uintptr(address&0xFFFFFFFF), // the call expects a 64-bit value
- uintptr(address>>32),
- uintptr(unsafe.Pointer(&buffer[0])),
- uintptr(size), // the call expects a 64-bit value
- uintptr(0), // but size is 32-bit so pass zero as the high dword
- uintptr(unsafe.Pointer(&read)),
- )
- if int(ret) >= 0 && read > 0 {
- return buffer[:uint(read)]
- }
+ ret, _, _ := common.ProcNtWow64ReadVirtualMemory64.Call(
+ uintptr(h),
+ uintptr(address&0xFFFFFFFF), // the call expects a 64-bit value
+ uintptr(address>>32),
+ uintptr(unsafe.Pointer(&buffer[0])),
+ uintptr(size), // the call expects a 64-bit value
+ uintptr(0), // but size is 32-bit so pass zero as the high dword
+ uintptr(unsafe.Pointer(&read)),
+ )
+ if int(ret) >= 0 && read > 0 {
+ return buffer[:uint(read)]
}
}
diff --git a/vendor/github.com/shirou/gopsutil/v4/process/process_windows_64bit.go b/vendor/github.com/shirou/gopsutil/v4/process/process_windows_64bit.go
index befe521..8cc26c3 100644
--- a/vendor/github.com/shirou/gopsutil/v4/process/process_windows_64bit.go
+++ b/vendor/github.com/shirou/gopsutil/v4/process/process_windows_64bit.go
@@ -7,11 +7,12 @@ import (
"syscall"
"unsafe"
- "github.com/shirou/gopsutil/v4/internal/common"
"golang.org/x/sys/windows"
+
+ "github.com/shirou/gopsutil/v4/internal/common"
)
-type PROCESS_MEMORY_COUNTERS struct {
+type PROCESS_MEMORY_COUNTERS struct { //nolint:revive //FIXME
CB uint32
PageFaultCount uint32
PeakWorkingSetSize uint64
@@ -38,26 +39,23 @@ func queryPebAddress(procHandle syscall.Handle, is32BitProcess bool) (uint64, er
)
if status := windows.NTStatus(ret); status == windows.STATUS_SUCCESS {
return uint64(wow64), nil
- } else {
- return 0, windows.NTStatus(ret)
}
- } else {
- // we are on a 64-bit process reading an external 64-bit process
- var info processBasicInformation64
+ return 0, windows.NTStatus(ret)
+ }
+ // we are on a 64-bit process reading an external 64-bit process
+ var info processBasicInformation64
- ret, _, _ := common.ProcNtQueryInformationProcess.Call(
- uintptr(procHandle),
- uintptr(common.ProcessBasicInformation),
- uintptr(unsafe.Pointer(&info)),
- uintptr(unsafe.Sizeof(info)),
- uintptr(0),
- )
- if status := windows.NTStatus(ret); status == windows.STATUS_SUCCESS {
- return info.PebBaseAddress, nil
- } else {
- return 0, windows.NTStatus(ret)
- }
+ ret, _, _ := common.ProcNtQueryInformationProcess.Call(
+ uintptr(procHandle),
+ uintptr(common.ProcessBasicInformation),
+ uintptr(unsafe.Pointer(&info)),
+ uintptr(unsafe.Sizeof(info)),
+ uintptr(0),
+ )
+ if status := windows.NTStatus(ret); status == windows.STATUS_SUCCESS {
+ return info.PebBaseAddress, nil
}
+ return 0, windows.NTStatus(ret)
}
func readProcessMemory(procHandle syscall.Handle, _ bool, address uint64, size uint) []byte {