diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2016-04-30 01:51:44 +0200 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2016-04-30 01:51:44 +0200 |
commit | a209a2630c3033c8b5334a3aafad3c0af341f1bf (patch) | |
tree | b0164ccdf299cb75bac260b4b55257bd3d74f0e0 /psutil | |
parent | 86a9560c48b4e6d011ab1f8428287a3b86adcc0c (diff) | |
download | psutil-a209a2630c3033c8b5334a3aafad3c0af341f1bf.tar.gz |
determine process status by using common parser method
Diffstat (limited to 'psutil')
-rw-r--r-- | psutil/_pslinux.py | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py index 110b261f..7a213a71 100644 --- a/psutil/_pslinux.py +++ b/psutil/_pslinux.py @@ -1369,15 +1369,11 @@ class Process(object): @wrap_exceptions def status(self): - with open_binary("%s/%s/status" % (self._procfs_path, self.pid)) as f: - for line in f: - if line.startswith(b"State:"): - letter = line.split()[1] - if PY3: - letter = letter.decode() - # XXX is '?' legit? (we're not supposed to return - # it anyway) - return PROC_STATUSES.get(letter, '?') + ret = self._parse_status() + if ret['status'] is None: + raise NotImplementedError("line 'Status' not found in %s" % ( + "%s/%s/status" % (self._procfs_path, self.pid))) + return ret['status'] @wrap_exceptions def open_files(self): |