From 86a164d83b36a283d0837afb383d30f6f2a7caae Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sun, 27 Sep 2009 20:12:29 +0000 Subject: Make _test_pty_eof() fork when writing to the slave_fd, since otherwise it would block on some platforms such as Darwin. svn path=/main/trunk/; revision=14451 --- pym/portage/__init__.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'pym') diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 05f7b86bd..3bc125b94 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -3768,10 +3768,18 @@ def _test_pty_eof(): termios.tcsetattr(slave_fd, termios.TCSANOW, mode) # Simulate a subprocess writing some data to the - # slave end of the pipe, and then exiting. - slave_file.write(_unicode_encode(test_string, - encoding='utf_8', errors='strict')) - slave_file.close() + # slave end of the pipe, and then exiting. Do a + # real fork here since otherwise slave_file.close() + # would block on some platforms such as Darwin. + pid = os.fork() + if pid == 0: + slave_file.write(_unicode_encode(test_string, + encoding='utf_8', errors='strict')) + slave_file.close() + os._exit(os.EX_OK) + else: + slave_file.close() + os.waitpid(pid, 0) eof = False data = [] -- cgit v1.2.3-1-g7c22