summaryrefslogtreecommitdiff
path: root/psutil/arch/windows
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2019-11-03 22:51:18 -0800
committerGiampaolo Rodola <g.rodola@gmail.com>2019-11-03 22:51:18 -0800
commit8b91eeb1c599a582c94967e9fe7c080712d9833e (patch)
treeb723c8248158dc64e0793fa9809ae78bdb96dc6d /psutil/arch/windows
parent2597253a31bc9f49772242cd249f30331d58fd7c (diff)
downloadpsutil-8b91eeb1c599a582c94967e9fe7c080712d9833e.tar.gz
fix #875, win, cwd/environ/cmdline(): retry with incremental timeout in case of ERROR_PARTIAL_COPY
Diffstat (limited to 'psutil/arch/windows')
-rw-r--r--psutil/arch/windows/process_info.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/psutil/arch/windows/process_info.c b/psutil/arch/windows/process_info.c
index bd568d56..62735728 100644
--- a/psutil/arch/windows/process_info.c
+++ b/psutil/arch/windows/process_info.c
@@ -512,7 +512,10 @@ psutil_get_process_data(long pid,
// read PEB
if (!ReadProcessMemory(hProcess, ppeb32, &peb32, sizeof(peb32), NULL)) {
- goto read_process_memory_error;
+ // May fail with ERROR_PARTIAL_COPY, see:
+ // https://github.com/giampaolo/psutil/issues/875
+ PyErr_SetFromWindowsErr(0);
+ goto error;
}
// read process parameters
@@ -522,7 +525,10 @@ psutil_get_process_data(long pid,
sizeof(procParameters32),
NULL))
{
- goto read_process_memory_error;
+ // May fail with ERROR_PARTIAL_COPY, see:
+ // https://github.com/giampaolo/psutil/issues/875
+ PyErr_SetFromWindowsErr(0);
+ goto error;
}
switch (kind) {
@@ -657,7 +663,10 @@ psutil_get_process_data(long pid,
sizeof(peb),
NULL))
{
- goto read_process_memory_error;
+ // May fail with ERROR_PARTIAL_COPY, see:
+ // https://github.com/giampaolo/psutil/issues/875
+ PyErr_SetFromWindowsErr(0);
+ goto error;
}
// read process parameters
@@ -667,7 +676,10 @@ psutil_get_process_data(long pid,
sizeof(procParameters),
NULL))
{
- goto read_process_memory_error;
+ // May fail with ERROR_PARTIAL_COPY, see:
+ // https://github.com/giampaolo/psutil/issues/875
+ PyErr_SetFromWindowsErr(0);
+ goto error;
}
switch (kind) {
@@ -718,7 +730,10 @@ psutil_get_process_data(long pid,
} else
#endif
if (!ReadProcessMemory(hProcess, src, buffer, size, NULL)) {
- goto read_process_memory_error;
+ // May fail with ERROR_PARTIAL_COPY, see:
+ // https://github.com/giampaolo/psutil/issues/875
+ PyErr_SetFromWindowsErr(0);
+ goto error;
}
CloseHandle(hProcess);
@@ -728,18 +743,6 @@ psutil_get_process_data(long pid,
return 0;
-read_process_memory_error:
- // see: https://github.com/giampaolo/psutil/issues/875
- if (GetLastError() == ERROR_PARTIAL_COPY) {
- psutil_debug("ReadProcessMemory() failed with ERROR_PARTIAL_COPY; "
- "converting to EACCES");
- AccessDenied("ReadProcessMemory() failed with ERROR_PARTIAL_COPY");
- }
- else {
- PyErr_SetFromWindowsErr(0);
- }
- goto error;
-
error:
if (hProcess != NULL)
CloseHandle(hProcess);