end18 / psutil

Automatically exported from code.google.com/p/psutil
Other
0 stars 0 forks source link

Process cpu_times() and memory_info() should raise NoSuchProcess for zombie processes #76

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

>>> import psutil
>>> p = psutil.Process(3276)
>>> p.is_running()
True
>>> p.get_cpu_times()
(0.015600099999999999, 0.015600099999999999)
>>> p.get_memory_info()
(20480, 0)
>>> p.kill()
>>> p.is_running()
False
>>> p.get_cpu_times()
(0.015600099999999999, 0.015600099999999999)
>>> p.get_memory_info()
(20480, 0)

What is the expected output? What do you see instead?
I'd expect NoSuchProcess to be raised after the process has been killed.

Please use labels and text to provide additional information.
The test suite containes the following tests which were disabled on Windows
because of this issue:

# XXX - these tests are supposed to work everywhere except
# Windows which keeps returning info for a dead process.
if not sys.platform.lower().startswith("win32"):
    self.assertRaises(psutil.NoSuchProcess, p.get_cpu_times)
    self.assertRaises(psutil.NoSuchProcess, p.get_cpu_percent)
    self.assertRaises(psutil.NoSuchProcess, p.get_memory_info)
    self.assertRaises(psutil.NoSuchProcess, p.get_memory_percent)

Original issue reported on code.google.com by billiej...@gmail.com on 22 Feb 2010 at 10:42

GoogleCodeExporter commented 9 years ago
Fixed as r512 by having used GetExitProcess() to check whether the handle 
returned by
OpenProcess() is still alive.
I'm thinking that maybe we should use GetExitProcess() every time we use 
OpenProcess().
It is also possible that other functions suffer the same issue.

Original comment by billiej...@gmail.com on 22 Feb 2010 at 11:15

GoogleCodeExporter commented 9 years ago
Indeed, we faced this same problem in issue 36 which wasn't addressed at that 
time.
Closing this out as a duplicate.

Original comment by billiej...@gmail.com on 22 Feb 2010 at 11:17

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Updated csets after the SVN -> Mercurial migration:
r512 == revision 27636ff3db58

Original comment by g.rodola on 2 Mar 2013 at 11:51