Fix pid_to_state()

This commit is contained in:
Alexey Avramov 2019-09-11 00:26:21 +09:00
parent f1754a3e8b
commit e3c0bb3ca1

5
nohang
View File

@ -420,11 +420,14 @@ def pid_to_state(pid):
""" """
try: try:
with open('/proc/' + pid + '/stat', 'rb') as f: with open('/proc/' + pid + '/stat', 'rb') as f:
return f.read(20).decode('utf-8', 'ignore').rpartition(')')[2][1] return f.read(40).decode('utf-8', 'ignore').rpartition(')')[2][1]
except FileNotFoundError: except FileNotFoundError:
return '' return ''
except ProcessLookupError: except ProcessLookupError:
return '' return ''
except IndexError:
with open('/proc/' + pid + '/stat', 'rb') as f:
return f.read().decode('utf-8', 'ignore').rpartition(')')[2][1]
def pid_to_name(pid): def pid_to_name(pid):