-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Linux] memory_full_info() incorrectly raise ZombieProcess (#2284)
...this happens, for example, with PID 2 (kthreadd): ``` >>> import psutil >>> psutil.Process(2).memory_info() pmem(rss=0, vms=0, shared=0, text=0, lib=0, data=0, dirty=0) >>> psutil.Process(2).memory_full_info() Traceback (most recent call last): File "/home/giampaolo/svn/psutil/psutil/_pslinux.py", line 1901, in _parse_smaps_rollup for line in f: ProcessLookupError: [Errno 3] No such process During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/giampaolo/svn/psutil/psutil/__init__.py", line 1091, in memory_full_info return self._proc.memory_full_info() File "/home/giampaolo/svn/psutil/psutil/_pslinux.py", line 1948, in memory_full_info uss, pss, swap = self._parse_smaps_rollup() File "/home/giampaolo/svn/psutil/psutil/_pslinux.py", line 1653, in wrapper return fun(self, *args, **kwargs) File "/home/giampaolo/svn/psutil/psutil/_pslinux.py", line 1913, in _parse_smaps_rollup raise ZombieProcess(self.pid, self._name, self._ppid) psutil.ZombieProcess: PID still exists but it's a zombie (pid=2) ``` The error originates from `/proc/pid/smaps_rollup`, which acts weirdly: it raises ESRCH / ENOENT for many PIDs, even if they're alive (also as root). In that case we'll have to use `/proc/pid/smaps` as fallback, which is slower but has a +50% success rate compared to ``/proc/pid/smaps_rollup``.
- Loading branch information
Showing
6 changed files
with
73 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters