diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2016-08-06 00:22:10 +0200 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2016-08-06 00:22:10 +0200 |
commit | 07b6faa0b358f7f4cafb6933a5a82bfe7e5031e2 (patch) | |
tree | 2bd7e26c0bbb45d71ffbb0585db428246083385f /psutil/_pssunos.py | |
parent | c01e00533389a4f3ad285caf65afe2e53c9c063f (diff) | |
download | psutil-07b6faa0b358f7f4cafb6933a5a82bfe7e5031e2.tar.gz |
#857: also threads() and memory_maps() may raise EOVERFLOW
Diffstat (limited to 'psutil/_pssunos.py')
-rw-r--r-- | psutil/_pssunos.py | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/psutil/_pssunos.py b/psutil/_pssunos.py index 382087aa..a9dcd6c8 100644 --- a/psutil/_pssunos.py +++ b/psutil/_pssunos.py @@ -33,6 +33,7 @@ __extra__all__ = ["CONN_IDLE", "CONN_BOUND", "PROCFS_PATH"] PAGE_SIZE = os.sysconf('SC_PAGE_SIZE') AF_LINK = cext_posix.AF_LINK +IS_64_BIT = sys.maxsize > 2**32 CONN_IDLE = "IDLE" CONN_BOUND = "BOUND" @@ -429,8 +430,7 @@ class Process(object): try: times = cext.proc_cpu_times(self.pid, self._procfs_path) except OSError as err: - is_64bit = sys.maxsize > 2**32 - if err.errno == errno.EOVERFLOW and not is_64bit: + if err.errno == errno.EOVERFLOW and not IS_64_BIT: # We may get here if we attempt to query a 64bit process # with a 32bit python. # Error originates from read() and also tools like "cat" @@ -504,6 +504,15 @@ class Process(object): utime, stime = cext.query_process_thread( self.pid, tid, procfs_path) except EnvironmentError as err: + if err.errno == errno.EOVERFLOW and not IS_64_BIT: + # We may get here if we attempt to query a 64bit process + # with a 32bit python. + # Error originates from read() and also tools like "cat" + # fail in the same way (!). + # Since there simply is no way to determine CPU times we + # return 0.0 as a fallback. See: + # https://github.com/giampaolo/psutil/issues/857 + continue # ENOENT == thread gone in meantime if err.errno == errno.ENOENT: hit_enoent = True @@ -603,7 +612,20 @@ class Process(object): procfs_path = self._procfs_path retlist = [] - rawlist = cext.proc_memory_maps(self.pid, procfs_path) + try: + rawlist = cext.proc_memory_maps(self.pid, procfs_path) + except OSError as err: + if err.errno == errno.EOVERFLOW and not IS_64_BIT: + # We may get here if we attempt to query a 64bit process + # with a 32bit python. + # Error originates from read() and also tools like "cat" + # fail in the same way (!). + # Since there simply is no way to determine CPU times we + # return 0.0 as a fallback. See: + # https://github.com/giampaolo/psutil/issues/857 + return [] + else: + raise hit_enoent = False for item in rawlist: addr, addrsize, perm, name, rss, anon, locked = item |