diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2016-10-05 03:01:58 +0200 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2016-10-05 03:01:58 +0200 |
commit | 1bdd7d4fcefe34a579c2409461bd273faf6e79b7 (patch) | |
tree | 0f980392d194e54a928dc9126f7198ba28c4921d | |
parent | b940247f6c85c307378bfa6b9c86d33f4b97a8d9 (diff) | |
download | psutil-1bdd7d4fcefe34a579c2409461bd273faf6e79b7.tar.gz |
fix task_for_pid err handling on OSX
-rw-r--r-- | psutil/_psutil_osx.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/psutil/_psutil_osx.c b/psutil/_psutil_osx.c index 050b9fd0..2cea8053 100644 --- a/psutil/_psutil_osx.c +++ b/psutil/_psutil_osx.c @@ -169,9 +169,10 @@ psutil_proc_exe(PyObject *self, PyObject *args) { if (! PyArg_ParseTuple(args, "l", &pid)) return NULL; + errno = 0; ret = proc_pidpath(pid, &buf, sizeof(buf)); if (ret == 0) { - psutil_raise_ad_or_nsp(pid); + psutil_raise_for_pid(pid, "proc_pidpath() syscall failed"); return NULL; } #if PY_MAJOR_VERSION >= 3 @@ -309,9 +310,11 @@ psutil_proc_memory_maps(PyObject *self, PyObject *args) { goto error; err = task_for_pid(mach_task_self(), pid, &task); - if (err != KERN_SUCCESS) { - psutil_raise_ad_or_nsp(pid); + if (psutil_pid_exists(pid) == 0) + NoSuchProcess(); + else + AccessDenied(); goto error; } @@ -578,7 +581,10 @@ psutil_proc_memory_uss(PyObject *self, PyObject *args) { err = task_for_pid(mach_task_self(), pid, &task); if (err != KERN_SUCCESS) { - psutil_raise_ad_or_nsp(pid); + if (psutil_pid_exists(pid) == 0) + NoSuchProcess(); + else + AccessDenied(); return NULL; } @@ -1025,7 +1031,10 @@ psutil_proc_threads(PyObject *self, PyObject *args) { // task_for_pid() requires special privileges err = task_for_pid(mach_task_self(), pid, &task); if (err != KERN_SUCCESS) { - psutil_raise_ad_or_nsp(pid); + if (psutil_pid_exists(pid) == 0) + NoSuchProcess(); + else + AccessDenied(); goto error; } |