summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2020-11-01 14:50:48 +0100
committerGiampaolo Rodola <g.rodola@gmail.com>2020-11-01 14:50:48 +0100
commit9b0efdd06aaac77e4579cab13d894ebed209749f (patch)
tree92477b2c35f1b12b80f3367e65bf1e39fd936d15
parenta570100f73f3e6899da19cf84d4fd6f41ddf1bc2 (diff)
downloadpsutil-9b0efdd06aaac77e4579cab13d894ebed209749f.tar.gz
fix #1868: missing fields from /proc/pid/stat on Alpine Linux
-rw-r--r--HISTORY.rst5
-rw-r--r--psutil/_pslinux.py11
2 files changed, 14 insertions, 2 deletions
diff --git a/HISTORY.rst b/HISTORY.rst
index 54f2d79f..fb8ec8f1 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -10,6 +10,11 @@ XXXX-XX-XX
- 1875_: `disk_partitions()` exposes 2 extra fields: `maxfile` and `maxpath`,
which are the maximum file name and path name length.
+**Bug fixes**
+
+- 1868_: [Linux] /proc/pid/stat is missing 2 fields on Alpine Linux (cpu_num
+ and delayacct_blkio_ticks) and are now being set to None.
+
5.7.3
=====
diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py
index b17b96a2..63b76697 100644
--- a/psutil/_pslinux.py
+++ b/psutil/_pslinux.py
@@ -1577,8 +1577,15 @@ class Process(object):
ret['children_utime'] = fields[13]
ret['children_stime'] = fields[14]
ret['create_time'] = fields[19]
- ret['cpu_num'] = fields[36]
- ret['blkio_ticks'] = fields[39] # aka 'delayacct_blkio_ticks'
+ # https://github.com/giampaolo/psutil/issues/1868
+ try:
+ ret['cpu_num'] = fields[36]
+ except IndexError:
+ ret['cpu_num'] = None
+ try:
+ ret['blkio_ticks'] = fields[39] # aka 'delayacct_blkio_ticks'
+ except IndexError:
+ ret['blkio_ticks'] = None
return ret