Skip to content

Commit 0057e4d

Browse files
dd-mergequeue[bot]Andreagit97brycekahle
authored
Merge pull request #49 from Andreagit97/fix-fill-from-stat
fix: do not read under `/proc/pid/stat` if empty Co-authored-by: Andreagit97 <[email protected]> Co-authored-by: bryce.kahle <[email protected]>
2 parents f019eab + 53a3242 commit 0057e4d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

process/process_linux.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,9 @@ func (p *Process) fillFromStat() (int32, int32, *cpu.TimesStat, int64, int32, er
867867
return 0, 0, nil, 0, 0, err
868868
}
869869
fields := strings.Fields(string(contents))
870+
if len(fields) == 0 {
871+
return 0, 0, nil, 0, 0, fmt.Errorf("stat file is empty for pid %d", pid)
872+
}
870873
timestamp := time.Now().Unix()
871874

872875
i := 1

0 commit comments

Comments
 (0)