1 |
Author: zmedico |
2 |
Date: 2009-09-27 21:55:41 +0000 (Sun, 27 Sep 2009) |
3 |
New Revision: 14454 |
4 |
|
5 |
Modified: |
6 |
main/trunk/pym/portage/__init__.py |
7 |
Log: |
8 |
Make _test_pty_eof() call process.spawn() instead of os.fork(). |
9 |
|
10 |
|
11 |
Modified: main/trunk/pym/portage/__init__.py |
12 |
=================================================================== |
13 |
--- main/trunk/pym/portage/__init__.py 2009-09-27 21:07:38 UTC (rev 14453) |
14 |
+++ main/trunk/pym/portage/__init__.py 2009-09-27 21:55:41 UTC (rev 14454) |
15 |
@@ -3768,14 +3768,15 @@ |
16 |
# slave end of the pipe, and then exiting. Do a |
17 |
# real fork here since otherwise os.close(slave_fd) |
18 |
# would block on some platforms such as Darwin. |
19 |
- pid = os.fork() |
20 |
- if pid == 0: |
21 |
- os.write(slave_fd, _unicode_encode(test_string, |
22 |
- encoding='utf_8', errors='strict')) |
23 |
+ pids = process.spawn_bash(_unicode_encode("echo -n '%s'" % test_string, |
24 |
+ encoding='utf_8', errors='strict'), env=os.environ, |
25 |
+ fd_pipes={0:sys.stdin.fileno(), 1:slave_fd, 2:slave_fd}, |
26 |
+ returnpid=True) |
27 |
+ if isinstance(pids, int): |
28 |
+ os.close(master_fd) |
29 |
os.close(slave_fd) |
30 |
- os._exit(os.EX_OK) |
31 |
- else: |
32 |
- os.close(slave_fd) |
33 |
+ raise EnvironmentError('spawn failed') |
34 |
+ os.close(slave_fd) |
35 |
|
36 |
master_file = os.fdopen(master_fd, 'rb') |
37 |
eof = False |
38 |
@@ -3806,7 +3807,7 @@ |
39 |
data.append(_unicode_decode(buf.tostring(), |
40 |
encoding='utf_8', errors='strict')) |
41 |
|
42 |
- os.waitpid(pid, 0) |
43 |
+ os.waitpid(pids[0], 0) |
44 |
master_file.close() |
45 |
|
46 |
return test_string == ''.join(data) |