summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2020-12-14 19:27:19 +0100
committerGiampaolo Rodola <g.rodola@gmail.com>2020-12-14 19:27:19 +0100
commitdb6ca4f3f052348d12055f290bcde25f14a63520 (patch)
tree511f3cf5c4386ce1a74d7714353f6d7dda883077
parent88469734c1c5fa5a38a00ebc91367ac36bed40ed (diff)
downloadpsutil-winerr-0.tar.gz
refactorwinerr-0
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
-rw-r--r--psutil/_psutil_common.c2
-rw-r--r--psutil/_psutil_osx.c2
-rw-r--r--psutil/_psutil_windows.c2
-rw-r--r--psutil/arch/osx/process_info.c2
-rw-r--r--psutil/arch/windows/process_info.c3
5 files changed, 7 insertions, 4 deletions
diff --git a/psutil/_psutil_common.c b/psutil/_psutil_common.c
index 2bf4ad79..fae8d970 100644
--- a/psutil/_psutil_common.c
+++ b/psutil/_psutil_common.c
@@ -106,7 +106,6 @@ NoSuchProcess(const char *syscall) {
char msg[1024];
sprintf(msg, "assume no such process (originated from %s)", syscall);
- psutil_debug(msg);
exc = PyObject_CallFunction(PyExc_OSError, "(is)", ESRCH, msg);
PyErr_SetObject(PyExc_OSError, exc);
Py_XDECREF(exc);
@@ -124,7 +123,6 @@ AccessDenied(const char *syscall) {
char msg[1024];
sprintf(msg, "assume access denied (originated from %s)", syscall);
- psutil_debug(msg);
exc = PyObject_CallFunction(PyExc_OSError, "(is)", EACCES, msg);
PyErr_SetObject(PyExc_OSError, exc);
Py_XDECREF(exc);
diff --git a/psutil/_psutil_osx.c b/psutil/_psutil_osx.c
index 8df186cb..33d46635 100644
--- a/psutil/_psutil_osx.c
+++ b/psutil/_psutil_osx.c
@@ -97,7 +97,7 @@ psutil_task_for_pid(pid_t pid, mach_port_t *task)
err = task_for_pid(mach_task_self(), pid, task);
if (err != KERN_SUCCESS) {
if (psutil_pid_exists(pid) == 0)
- NoSuchProcess("task_for_pid -> psutil_pid_exists -> 0");
+ NoSuchProcess("task_for_pid");
else if (psutil_is_zombie(pid) == 1)
PyErr_SetString(ZombieProcessError,
"task_for_pid -> psutil_is_zombie -> 1");
diff --git a/psutil/_psutil_windows.c b/psutil/_psutil_windows.c
index 66177985..513d6c24 100644
--- a/psutil/_psutil_windows.c
+++ b/psutil/_psutil_windows.c
@@ -701,7 +701,7 @@ psutil_proc_threads(PyObject *self, PyObject *args) {
if (pid == 0) {
// raise AD instead of returning 0 as procexp is able to
// retrieve useful information somehow
- AccessDenied("automatically set for PID 0");
+ AccessDenied("forced for PID 0");
goto error;
}
diff --git a/psutil/arch/osx/process_info.c b/psutil/arch/osx/process_info.c
index eda60c38..fb9f24ff 100644
--- a/psutil/arch/osx/process_info.c
+++ b/psutil/arch/osx/process_info.c
@@ -131,11 +131,13 @@ psutil_sysctl_procargs(pid_t pid, char *procargs, size_t argmax) {
// In case of zombie process we'll get EINVAL. We translate it
// to NSP and _psosx.py will translate it to ZP.
if (errno == EINVAL) {
+ psutil_debug("sysctl(KERN_PROCARGS2) -> EINVAL translated to NSP");
NoSuchProcess("sysctl(KERN_PROCARGS2) -> EINVAL");
return 1;
}
// There's nothing we can do other than raising AD.
if (errno == EIO) {
+ psutil_debug("sysctl(KERN_PROCARGS2) -> EIO translated to AD");
AccessDenied("sysctl(KERN_PROCARGS2) -> EIO");
return 1;
}
diff --git a/psutil/arch/windows/process_info.c b/psutil/arch/windows/process_info.c
index 80b38d6d..ac306536 100644
--- a/psutil/arch/windows/process_info.c
+++ b/psutil/arch/windows/process_info.c
@@ -56,6 +56,7 @@ psutil_convert_winerr(ULONG err, char* syscall) {
if (err == ERROR_NOACCESS) {
sprintf(fullmsg, "%s -> ERROR_NOACCESS", syscall);
+ psutil_debug(fullmsg);
AccessDenied(fullmsg);
}
else {
@@ -429,6 +430,8 @@ psutil_cmdline_query_proc(DWORD pid, WCHAR **pdata, SIZE_T *psize) {
// https://github.com/giampaolo/psutil/issues/1501
if (status == STATUS_NOT_FOUND) {
+ psutil_debug("NtQueryInformationProcess(ProcessBasicInformation) -> "
+ "STATUS_NOT_FOUND turned into AD")
AccessDenied("NtQueryInformationProcess(ProcessBasicInformation) -> "
"STATUS_NOT_FOUND");
goto error;