summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola' <g.rodola@gmail.com>2013-04-11 15:17:27 +0200
committerGiampaolo Rodola' <g.rodola@gmail.com>2013-04-11 15:17:27 +0200
commitb1aa590fafde5cbf312de5ef81640c7a06f887d7 (patch)
tree9a062d8a7cb6c3e2f776f2eec0df7549fe067bba
parent4f646201fe53f71638e92c6a2d9c06d3ae88b87d (diff)
downloadpsutil-b1aa590fafde5cbf312de5ef81640c7a06f887d7.tar.gz
Issue 365 / wait(): cannot make the PID reuse check on Windows as we can determine the exit code also from a dead process.
-rw-r--r--HISTORY6
-rw-r--r--psutil/__init__.py16
2 files changed, 14 insertions, 8 deletions
diff --git a/HISTORY b/HISTORY
index 0d1d833c..69b95c28 100644
--- a/HISTORY
+++ b/HISTORY
@@ -44,8 +44,10 @@ BUG FIXES
* #353: [OSX] get_users() returns an empty list on OSX 10.8.
* #356: Process.parent now checks whether parent PID has been reused in which
case returns None.
- * #365: Process wait() and set_nice() methods should check PID has not been
- reused by another process.
+ * #365: [UNIX] Process.wait() should check PID has not been reused by another
+ process.
+ * #365: Process.set_nice() should check PID has not been reused by another
+ process.
API CHANGES
diff --git a/psutil/__init__.py b/psutil/__init__.py
index 720c0d12..1d444fcb 100644
--- a/psutil/__init__.py
+++ b/psutil/__init__.py
@@ -780,13 +780,17 @@ class Process(object):
def wait(self, timeout=None):
"""Wait for process to terminate and, if process is a children
of the current one also return its exit code, else None.
- It also makes sure this process PID has not been reused by
- another process. If that's the case returns immediately.
+ On UNIX it first makes sure this process PID has not been reused by
+ another process in which case returns immediately.
"""
- if self.is_running():
- if timeout is not None and not timeout >= 0:
- raise ValueError("timeout must be a positive integer")
- return self._platform_impl.process_wait(timeout)
+ if timeout is not None and not timeout >= 0:
+ raise ValueError("timeout must be a positive integer")
+ # cannot check PID reuse on Windows as we're able to determine
+ # exit code also from a dead process
+ if os.name == 'posix':
+ if not self.is_running():
+ return
+ return self._platform_impl.process_wait(timeout)
# --- deprecated API