summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/compat/_subprocess.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/SCons/compat/_subprocess.py')
-rw-r--r--src/engine/SCons/compat/_subprocess.py24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/engine/SCons/compat/_subprocess.py b/src/engine/SCons/compat/_subprocess.py
index aa17cae..fc06347 100644
--- a/src/engine/SCons/compat/_subprocess.py
+++ b/src/engine/SCons/compat/_subprocess.py
@@ -356,6 +356,7 @@ import sys
mswindows = (sys.platform == "win32")
import os
+import string
import types
import traceback
@@ -565,7 +566,7 @@ def list2cmdline(seq):
result.extend(bs_buf)
result.append('"')
- return ''.join(result)
+ return string.join(result, '')
try:
@@ -1048,12 +1049,8 @@ class Popen(object):
# Close pipe fds. Make sure we don't close the same
# fd more than once, or standard fds.
- if p2cread:
- os.close(p2cread)
- if c2pwrite and c2pwrite not in (p2cread,):
- os.close(c2pwrite)
- if errwrite and errwrite not in (p2cread, c2pwrite):
- os.close(errwrite)
+ for fd in set((p2cread, c2pwrite, errwrite))-set((0,1,2)):
+ if fd: os.close(fd)
# Close all other fds, if asked for
if close_fds:
@@ -1079,7 +1076,7 @@ class Popen(object):
exc_lines = traceback.format_exception(exc_type,
exc_value,
tb)
- exc_value.child_traceback = ''.join(exc_lines)
+ exc_value.child_traceback = string.join(exc_lines, '')
os.write(errpipe_write, pickle.dumps(exc_value))
# This exitcode won't be reported to applications, so it
@@ -1158,6 +1155,7 @@ class Popen(object):
read_set.append(self.stderr)
stderr = []
+ input_offset = 0
while read_set or write_set:
rlist, wlist, xlist = select.select(read_set, write_set, [])
@@ -1165,9 +1163,9 @@ class Popen(object):
# When select has indicated that the file is writable,
# we can write up to PIPE_BUF bytes without risk
# blocking. POSIX defines PIPE_BUF >= 512
- bytes_written = os.write(self.stdin.fileno(), input[:512])
- input = input[bytes_written:]
- if not input:
+ bytes_written = os.write(self.stdin.fileno(), buffer(input, input_offset, 512))
+ input_offset = input_offset + bytes_written
+ if input_offset >= len(input):
self.stdin.close()
write_set.remove(self.stdin)
@@ -1187,9 +1185,9 @@ class Popen(object):
# All data exchanged. Translate lists into strings.
if stdout is not None:
- stdout = ''.join(stdout)
+ stdout = string.join(stdout, '')
if stderr is not None:
- stderr = ''.join(stderr)
+ stderr = string.join(stderr, '')
# Translate newlines, if requested. We cannot let the file
# object do the translation: It is based on stdio, which is