summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-09-27 21:55:41 +0000
committerZac Medico <zmedico@gentoo.org>2009-09-27 21:55:41 +0000
commit593d2c482b56254ad153a99087058d3c94515090 (patch)
tree5364a0f7ad8e38b4adb21d755a1da0cca48e8993
parentbea2e46fe5a942f492c495eaca2e31f4e56c8c53 (diff)
downloadportage-593d2c482b56254ad153a99087058d3c94515090.tar.gz
portage-593d2c482b56254ad153a99087058d3c94515090.tar.bz2
portage-593d2c482b56254ad153a99087058d3c94515090.zip
Make _test_pty_eof() call process.spawn() instead of os.fork().
svn path=/main/trunk/; revision=14454
-rw-r--r--pym/portage/__init__.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index b8bd4343b..d486227dc 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -3768,14 +3768,15 @@ def _test_pty_eof():
# slave end of the pipe, and then exiting. Do a
# real fork here since otherwise os.close(slave_fd)
# would block on some platforms such as Darwin.
- pid = os.fork()
- if pid == 0:
- os.write(slave_fd, _unicode_encode(test_string,
- encoding='utf_8', errors='strict'))
- os.close(slave_fd)
- os._exit(os.EX_OK)
- else:
+ pids = process.spawn_bash(_unicode_encode("echo -n '%s'" % test_string,
+ encoding='utf_8', errors='strict'), env=os.environ,
+ fd_pipes={0:sys.stdin.fileno(), 1:slave_fd, 2:slave_fd},
+ returnpid=True)
+ if isinstance(pids, int):
+ os.close(master_fd)
os.close(slave_fd)
+ raise EnvironmentError('spawn failed')
+ os.close(slave_fd)
master_file = os.fdopen(master_fd, 'rb')
eof = False
@@ -3806,7 +3807,7 @@ def _test_pty_eof():
data.append(_unicode_decode(buf.tostring(),
encoding='utf_8', errors='strict'))
- os.waitpid(pid, 0)
+ os.waitpid(pids[0], 0)
master_file.close()
return test_string == ''.join(data)