~ubuntu-branches/ubuntu/lucid/python2.6/lucid

« back to all changes in this revision

Viewing changes to Lib/subprocess.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2010-03-11 13:30:19 UTC
  • mto: (10.1.13 sid)
  • mto: This revision was merged to the branch mainline in revision 44.
  • Revision ID: james.westby@ubuntu.com-20100311133019-sblbooa3uqrkoe70
Tags: upstream-2.6.5~rc2
ImportĀ upstreamĀ versionĀ 2.6.5~rc2

Show diffs side-by-side

added added

removed removed

Lines of Context:
459
459
STDOUT = -2
460
460
 
461
461
 
 
462
def _eintr_retry_call(func, *args):
 
463
    while True:
 
464
        try:
 
465
            return func(*args)
 
466
        except OSError, e:
 
467
            if e.errno == errno.EINTR:
 
468
                continue
 
469
            raise
 
470
 
 
471
 
462
472
def call(*popenargs, **kwargs):
463
473
    """Run command with arguments.  Wait for command to complete, then
464
474
    return the returncode attribute.
516
526
    """
517
527
 
518
528
    # See
519
 
    # http://msdn.microsoft.com/library/en-us/vccelng/htm/progs_12.asp
 
529
    # http://msdn.microsoft.com/en-us/library/17w5ykft.aspx
 
530
    # or search http://msdn.microsoft.com for
 
531
    # "Parsing C++ Command-Line Arguments"
520
532
    result = []
521
533
    needquote = False
522
534
    for arg in seq:
1112
1124
                    os.close(errwrite)
1113
1125
 
1114
1126
                # Wait for exec to fail or succeed; possibly raising exception
1115
 
                data = os.read(errpipe_read, 1048576) # Exceptions limited to 1 MB
 
1127
                # Exception limited to 1M
 
1128
                data = _eintr_retry_call(os.read, errpipe_read, 1048576)
1116
1129
            finally:
1117
1130
                # be sure the FD is closed no matter what
1118
1131
                os.close(errpipe_read)
1119
1132
 
1120
1133
            if data != "":
1121
 
                os.waitpid(self.pid, 0)
 
1134
                _eintr_retry_call(os.waitpid, self.pid, 0)
1122
1135
                child_exception = pickle.loads(data)
1123
1136
                for fd in (p2cwrite, c2pread, errread):
1124
1137
                    if fd is not None:
1154
1167
            """Wait for child process to terminate.  Returns returncode
1155
1168
            attribute."""
1156
1169
            if self.returncode is None:
1157
 
                pid, sts = os.waitpid(self.pid, 0)
 
1170
                pid, sts = _eintr_retry_call(os.waitpid, self.pid, 0)
1158
1171
                self._handle_exitstatus(sts)
1159
1172
            return self.returncode
1160
1173