diff --git a/psutil/_psosx.py b/psutil/_psosx.py index b86cfb343..a69f892c6 100644 --- a/psutil/_psosx.py +++ b/psutil/_psosx.py @@ -518,7 +518,8 @@ def status(self): @wrap_exceptions def threads(self): - rawlist = cext.proc_threads(self.pid) + with catch_zombie(self): + rawlist = cext.proc_threads(self.pid) retlist = [] for thread_id, utime, stime in rawlist: ntuple = _common.pthread(thread_id, utime, stime) diff --git a/psutil/_psutil_osx.c b/psutil/_psutil_osx.c index 2ec51eeda..92d48dd4d 100644 --- a/psutil/_psutil_osx.c +++ b/psutil/_psutil_osx.c @@ -1006,10 +1006,7 @@ psutil_proc_threads(PyObject *self, PyObject *args) { // task_for_pid() requires special privileges 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; }