summaryrefslogtreecommitdiff
path: root/vendor/github.com/shirou/gopsutil/v4/process/process_linux.go
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-07-04 11:12:51 -0600
committermo khan <mo@mokhan.ca>2025-07-04 11:12:51 -0600
commit12736451bf5e7773ff41794d537fa1c3bdbe7912 (patch)
tree082afeaa70151ff071d9063876003bd217fa53fc /vendor/github.com/shirou/gopsutil/v4/process/process_linux.go
parenta4d071362fde79e346ae5fe600c16ae71967167f (diff)
chore: update modules
Diffstat (limited to 'vendor/github.com/shirou/gopsutil/v4/process/process_linux.go')
-rw-r--r--vendor/github.com/shirou/gopsutil/v4/process/process_linux.go22
1 files changed, 7 insertions, 15 deletions
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 bf96fd3..f44f6bc 100644
--- a/vendor/github.com/shirou/gopsutil/v4/process/process_linux.go
+++ b/vendor/github.com/shirou/gopsutil/v4/process/process_linux.go
@@ -358,7 +358,7 @@ func (p *Process) ChildrenWithContext(ctx context.Context) ([]*Process, error) {
if err != nil {
continue
}
- if int32(ppid) == p.Pid {
+ if ppid == int64(p.Pid) {
np, err := NewProcessWithContext(ctx, int32(pid))
if err != nil {
continue
@@ -372,15 +372,7 @@ func (p *Process) ChildrenWithContext(ctx context.Context) ([]*Process, error) {
func (p *Process) OpenFilesWithContext(ctx context.Context) ([]OpenFilesStat, error) {
_, ofs, err := p.fillFromfdWithContext(ctx)
- if err != nil {
- return nil, err
- }
- ret := make([]OpenFilesStat, len(ofs))
- for i, o := range ofs {
- ret[i] = *o
- }
-
- return ret, nil
+ return ofs, err
}
func (p *Process) ConnectionsWithContext(ctx context.Context) ([]net.ConnectionStat, error) {
@@ -629,17 +621,17 @@ func (p *Process) fillFromfdListWithContext(ctx context.Context) (string, []stri
}
// Get num_fds from /proc/(pid)/fd
-func (p *Process) fillFromfdWithContext(ctx context.Context) (int32, []*OpenFilesStat, error) {
+func (p *Process) fillFromfdWithContext(ctx context.Context) (int32, []OpenFilesStat, error) {
statPath, fnames, err := p.fillFromfdListWithContext(ctx)
if err != nil {
return 0, nil, err
}
numFDs := int32(len(fnames))
- var openfiles []*OpenFilesStat
+ openfiles := make([]OpenFilesStat, 0, numFDs)
for _, fd := range fnames {
fpath := filepath.Join(statPath, fd)
- filepath, err := os.Readlink(fpath)
+ path, err := common.Readlink(fpath)
if err != nil {
continue
}
@@ -647,8 +639,8 @@ func (p *Process) fillFromfdWithContext(ctx context.Context) (int32, []*OpenFile
if err != nil {
return numFDs, openfiles, err
}
- o := &OpenFilesStat{
- Path: filepath,
+ o := OpenFilesStat{
+ Path: path,
Fd: t,
}
openfiles = append(openfiles, o)