summaryrefslogtreecommitdiffstats
path: root/Lib/subprocess.py
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2010-03-01 00:17:40 (GMT)
committerGregory P. Smith <greg@mad-scientist.com>2010-03-01 00:17:40 (GMT)
commita59c59f9460ddc9c9a54965414c60be50ee5873b (patch)
treef006e014b6b553425962c0aa6f9c2b1e1736a3b9 /Lib/subprocess.py
parent3fdd9648cb6974324ee31d81541b1dca5fb830d8 (diff)
downloadcpython-a59c59f9460ddc9c9a54965414c60be50ee5873b.zip
cpython-a59c59f9460ddc9c9a54965414c60be50ee5873b.tar.gz
cpython-a59c59f9460ddc9c9a54965414c60be50ee5873b.tar.bz2
Merged revisions 78523 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r78523 | gregory.p.smith | 2010-02-28 16:05:08 -0800 (Sun, 28 Feb 2010) | 3 lines Issue #1068268: The subprocess module now handles EINTR in internal os.waitpid and os.read system calls where appropriate. ........
Diffstat (limited to 'Lib/subprocess.py')
-rw-r--r--Lib/subprocess.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index 6e753cb..3017432 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -406,6 +406,16 @@ PIPE = -1
STDOUT = -2
+def _eintr_retry_call(func, *args):
+ while True:
+ try:
+ return func(*args)
+ except OSError as e:
+ if e.errno == errno.EINTR:
+ continue
+ raise
+
+
def call(*popenargs, **kwargs):
"""Run command with arguments. Wait for command to complete, then
return the returncode attribute.
@@ -1133,13 +1143,13 @@ class Popen(object):
# Wait for exec to fail or succeed; possibly raising an
# exception (limited to 1 MB)
- data = os.read(errpipe_read, 1048576)
+ data = _eintr_retry_call(os.read, errpipe_read, 1048576)
finally:
# be sure the FD is closed no matter what
os.close(errpipe_read)
if data:
- os.waitpid(self.pid, 0)
+ _eintr_retry_call(os.waitpid, self.pid, 0)
child_exception = pickle.loads(data)
for fd in (p2cwrite, c2pread, errread):
if fd is not None:
@@ -1175,7 +1185,7 @@ class Popen(object):
"""Wait for child process to terminate. Returns returncode
attribute."""
if self.returncode is None:
- pid, sts = os.waitpid(self.pid, 0)
+ pid, sts = _eintr_retry_call(os.waitpid, self.pid, 0)
self._handle_exitstatus(sts)
return self.returncode