feat(dev): fix proc type when there is no pid
This commit is contained in:
parent
7803be576c
commit
5e29cda97c
|
@ -103,7 +103,8 @@ func stat(pid int, statType string) (*SysInfo, error) {
|
||||||
|
|
||||||
procStatFileBytes, err := ioutil.ReadFile(path.Join("/proc", strconv.Itoa(pid), "stat"))
|
procStatFileBytes, err := ioutil.ReadFile(path.Join("/proc", strconv.Itoa(pid), "stat"))
|
||||||
splitAfter := strings.SplitAfter(string(procStatFileBytes), ")")
|
splitAfter := strings.SplitAfter(string(procStatFileBytes), ")")
|
||||||
if len(splitAfter) == 0 {
|
|
||||||
|
if len(splitAfter) == 0 || len(splitAfter) == 1 {
|
||||||
return sysInfo, errors.New("can not foud this pid: " + strconv.Itoa(pid))
|
return sysInfo, errors.New("can not foud this pid: " + strconv.Itoa(pid))
|
||||||
}
|
}
|
||||||
infos := strings.Split(splitAfter[1], " ")
|
infos := strings.Split(splitAfter[1], " ")
|
||||||
|
|
Loading…
Reference in New Issue