diff options
author | Frank Benkstein <frank.benkstein@sap.com> | 2016-01-29 15:39:41 +0100 |
---|---|---|
committer | Frank Benkstein <frank.benkstein@sap.com> | 2016-01-29 15:55:20 +0100 |
commit | 3924664725ab03c3ff114d776da0fcc3952e891d (patch) | |
tree | 6a3b7b38a6da66cc337e4b5a67e043142da5be33 | |
parent | 95c127aa194035d7cdcb143d0cb02ab4726d1f95 (diff) | |
download | psutil-3924664725ab03c3ff114d776da0fcc3952e891d.tar.gz |
handle vanishing proceses when accessing memory
-rw-r--r-- | psutil/_psutil_windows.c | 2 | ||||
-rw-r--r-- | psutil/_pswindows.py | 5 |
2 files changed, 7 insertions, 0 deletions
diff --git a/psutil/_psutil_windows.c b/psutil/_psutil_windows.c index c351a2ba..aa80519e 100644 --- a/psutil/_psutil_windows.c +++ b/psutil/_psutil_windows.c @@ -3204,6 +3204,8 @@ void init_psutil_windows(void) module, "INFINITE", INFINITE); PyModule_AddIntConstant( module, "ERROR_ACCESS_DENIED", ERROR_ACCESS_DENIED); + PyModule_AddIntConstant( + module, "ERROR_PARTIAL_COPY", ERROR_PARTIAL_COPY); // set SeDebug for the current process psutil_set_se_debug(); diff --git a/psutil/_pswindows.py b/psutil/_pswindows.py index 83f88765..4d39d84f 100644 --- a/psutil/_pswindows.py +++ b/psutil/_pswindows.py @@ -288,6 +288,11 @@ def wrap_exceptions(fun): raise AccessDenied(self.pid, self._name) if err.errno == errno.ESRCH: raise NoSuchProcess(self.pid, self._name) + if getattr(err, "winerror", 0) == cext.ERROR_PARTIAL_COPY: + if pid_exists(self.pid): + raise AccessDenied(self.pid, self._name) + else: + raise NoSuchProcess(self.pid, self._name) raise return wrapper |