summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2017-06-02 18:25:24 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2017-06-02 18:25:24 +0200
commit05492344c1f426d9fae8f99f780ad5df27fbfee8 (patch)
treee0dfc99d9812281b0fd138769eeca38ca23a0e98
parent046b74786e8b9e96563f0e78ba0615060221e65b (diff)
downloadpsutil-05492344c1f426d9fae8f99f780ad5df27fbfee8.tar.gz
#1044: memory_maps() was incorrectly raising AD instead of ZombieProcess
-rw-r--r--psutil/_psosx.py3
-rw-r--r--psutil/_psutil_osx.c5
-rwxr-xr-xpsutil/tests/test_osx.py30
3 files changed, 33 insertions, 5 deletions
diff --git a/psutil/_psosx.py b/psutil/_psosx.py
index 2048c888..b86cfb34 100644
--- a/psutil/_psosx.py
+++ b/psutil/_psosx.py
@@ -527,4 +527,5 @@ class Process(object):
@wrap_exceptions
def memory_maps(self):
- return cext.proc_memory_maps(self.pid)
+ with catch_zombie(self):
+ return cext.proc_memory_maps(self.pid)
diff --git a/psutil/_psutil_osx.c b/psutil/_psutil_osx.c
index e562c954..2ec51eed 100644
--- a/psutil/_psutil_osx.c
+++ b/psutil/_psutil_osx.c
@@ -336,10 +336,7 @@ psutil_proc_memory_maps(PyObject *self, PyObject *args) {
err = task_for_pid(mach_task_self(), (pid_t)pid, &task);
if (err != KERN_SUCCESS) {
- if (psutil_pid_exists(pid) == 0)
- NoSuchProcess();
- else
- AccessDenied();
+ psutil_raise_for_pid(pid, "task_for_pid() failed");
goto error;
}
diff --git a/psutil/tests/test_osx.py b/psutil/tests/test_osx.py
index 6a327e52..c33cdb9a 100755
--- a/psutil/tests/test_osx.py
+++ b/psutil/tests/test_osx.py
@@ -129,6 +129,36 @@ class TestZombieProcessAPIs(unittest.TestCase):
def test_environ(self):
self.assertRaises(psutil.ZombieProcess, self.p.environ)
+ def test_cwd(self):
+ self.assertRaises(psutil.ZombieProcess, self.p.cwd)
+
+ def test_memory_full_info(self):
+ self.assertRaises(psutil.ZombieProcess, self.p.memory_full_info)
+
+ def test_cpu_times(self):
+ self.assertRaises(psutil.ZombieProcess, self.p.cpu_times)
+
+ def test_num_ctx_switches(self):
+ self.assertRaises(psutil.ZombieProcess, self.p.num_ctx_switches)
+
+ def test_num_threads(self):
+ self.assertRaises(psutil.ZombieProcess, self.p.num_threads)
+
+ def test_open_files(self):
+ self.assertRaises(psutil.ZombieProcess, self.p.open_files)
+
+ def test_connections(self):
+ self.assertRaises(psutil.ZombieProcess, self.p.connections)
+
+ def test_num_fds(self):
+ self.assertRaises(psutil.ZombieProcess, self.p.num_fds)
+
+ def test_threads(self):
+ self.assertRaises(psutil.ZombieProcess, self.p.threads)
+
+ def test_memory_maps(self):
+ self.assertRaises(psutil.ZombieProcess, self.p.memory_maps)
+
@unittest.skipIf(not OSX, "OSX only")
class TestSystemAPIs(unittest.TestCase):