public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] portage r14454 - main/trunk/pym/portage
@ 2009-09-27 21:55 Zac Medico (zmedico)
  0 siblings, 0 replies; only message in thread
From: Zac Medico (zmedico) @ 2009-09-27 21:55 UTC (permalink / raw
  To: gentoo-commits

Author: zmedico
Date: 2009-09-27 21:55:41 +0000 (Sun, 27 Sep 2009)
New Revision: 14454

Modified:
   main/trunk/pym/portage/__init__.py
Log:
Make _test_pty_eof() call process.spawn() instead of os.fork().


Modified: main/trunk/pym/portage/__init__.py
===================================================================
--- main/trunk/pym/portage/__init__.py	2009-09-27 21:07:38 UTC (rev 14453)
+++ main/trunk/pym/portage/__init__.py	2009-09-27 21:55:41 UTC (rev 14454)
@@ -3768,14 +3768,15 @@
 	# 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'))
+	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)
-		os._exit(os.EX_OK)
-	else:
-		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 @@
 			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)




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-09-27 21:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-27 21:55 [gentoo-commits] portage r14454 - main/trunk/pym/portage Zac Medico (zmedico)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox