psutil: Process.status() returns 'running' for a ZombieProcess
This is on a Mac OSX El Capitan Here is a quick session to demonstrate. Process 70 on my machine right now is indeed a zombie process.
Python 2.7.10 (default, Jun 10 2015, 19:43:32)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import psutil
>>> psutil.__version__
'4.0.0'
>>> p = psutil.Process(pid=70)
>>> p.status()
'running'
>>> p.name()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/gigi/.virtualenvs/work/lib/python2.7/site-packages/psutil/__init__.py", line 564, in name
cmdline = self.cmdline()
File "/Users/gigi/.virtualenvs/work/lib/python2.7/site-packages/psutil/__init__.py", line 617, in cmdline
return self._proc.cmdline()
File "/Users/gigi/.virtualenvs/work/lib/python2.7/site-packages/psutil/_psosx.py", line 207, in wrapper
raise ZombieProcess(self.pid, self._name, self._ppid)
psutil.ZombieProcess: psutil.ZombieProcess process still exists but it's a zombie (pid=70)
I followed the code to the status() method in _psxosx.py to see why it returns ‘running’
@wrap_exceptions
def status(self):
code = cext.proc_status(self.pid)
# XXX is '?' legit? (we're not supposed to return it anyway)
return PROC_STATUSES.get(code, '?')
The cext.proc_status(self.pid) returns 2, which is the code for ‘running’.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 32 (17 by maintainers)
Commits related to this issue
- Merge pull request #908 from giampaolo/refactor-c-pid-exists Refactor C psutil_pid_exists(), fixes #783 and #855 — committed to giampaolo/psutil by giampaolo 8 years ago
- #783: fix some unicode related test failures on osx — committed to giampaolo/psutil by giampaolo 8 years ago
- Merge branch 'master' into pslisten * master: (375 commits) update psutil fix procsmem script which was not printing processes try to fix tests on travis try to fix tests on travis OSX: fix... — committed to nlevitt/psutil by nlevitt 8 years ago
If Apple provided up to date OS images which developers could use in Azure or AWS (like Microsoft does!), maybe this wouldn’t be such an issue.
Most developers are not going to bother paying $1000s of bucks to verify if the free & gratis code they are shipping (at no cost) works on a platform they don’t use.
This is entirely Apple’s failing.