Skip to content

Commit

Permalink
fix #1181: raise AD if task_for_pid() fails with 5 and errno == ENOENT
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Nov 24, 2017
1 parent 04e8672 commit d43ee30
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- 1169_: [Linux] users() "hostname" returns username instead. (patch by
janderbrain)
- 1172_: [Windows] `make test` does not work.
- 1181_: [OSX] Process.memory_maps() may raise ENOENT.

5.4.1
=====
Expand Down
12 changes: 10 additions & 2 deletions psutil/_psutil_osx.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,16 @@ psutil_proc_memory_maps(PyObject *self, PyObject *args) {

err = task_for_pid(mach_task_self(), (pid_t)pid, &task);
if (err != KERN_SUCCESS) {
psutil_debug("task_for_pid() failed"); // TODO temporary
psutil_raise_for_pid(pid, "task_for_pid()");
if ((err == 5) && (errno == ENOENT)) {
// See: https://github.com/giampaolo/psutil/issues/1181
psutil_debug("task_for_pid(MACH_PORT_NULL) failed; err=%i, "
"errno=%i, msg='%s'\n", err, errno,
mach_error_string(err));
AccessDenied("");
}
else {
psutil_raise_for_pid(pid, "task_for_pid(MACH_PORT_NULL)");
}
goto error;
}

Expand Down

0 comments on commit d43ee30

Please sign in to comment.