diff options
author | SeongJae Park <sj@kernel.org> | 2024-04-15 11:25:18 -0700 |
---|---|---|
committer | SeongJae Park <sj@kernel.org> | 2024-04-15 11:26:38 -0700 |
commit | a25188c7ca61851b368e18caf0a8cbf7e92a51ad (patch) | |
tree | f4250a6ffa7fab55c29fe4b36950187c958690c7 | |
parent | f4ace2376a0d7dd67c259bc77c7a742546e0c298 (diff) | |
download | damo-a25188c7ca61851b368e18caf0a8cbf7e92a51ad.tar.gz |
_damo_records: Handle a case where a process finished while collecting memory footprint
The target process could be terminated while collecting memory
footprint. Handle the case by treating the process as just not using
memory anymore.
Signed-off-by: SeongJae Park <sj@kernel.org>
-rw-r--r-- | _damo_records.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/_damo_records.py b/_damo_records.py index 914a5333..3c0faa85 100644 --- a/_damo_records.py +++ b/_damo_records.py @@ -532,8 +532,12 @@ class MemFootprint: if pid is None: return - with open('/proc/%s/statm' % pid, 'r') as f: - fields = [int(x) for x in f.read().split()] + try: + with open('/proc/%s/statm' % pid, 'r') as f: + fields = [int(x) for x in f.read().split()] + except: + # the process may terminated. Just think it as not using memory. + fields = [0 for _ in range(7)] self.size = fields[0] self.resident = fields[1] self.shared = fields[2] |