For pty logging, handle the EAGAIN error that is thrown from fcntl when the slave...
authorZac Medico <zmedico@gentoo.org>
Sun, 29 Jul 2007 02:09:22 +0000 (02:09 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 29 Jul 2007 02:09:22 +0000 (02:09 -0000)
svn path=/main/trunk/; revision=7424

pym/portage/__init__.py

index b4c297e285be54a93fc161dfd323061033c3d879..e5730203d2b70ed57f60fb2a65b4e676b074cba9 100644 (file)
@@ -2469,8 +2469,16 @@ def spawn(mystring, mysettings, debug=0, free=0, droppriv=0, sesandbox=0, fakero
                        for f in events[0]:
                                # Use non-blocking mode to prevent read
                                # calls from blocking indefinitely.
-                               fcntl.fcntl(f.fileno(), fcntl.F_SETFL,
-                                       fd_flags[f] | os.O_NONBLOCK)
+                               try:
+                                       fcntl.fcntl(f.fileno(), fcntl.F_SETFL,
+                                               fd_flags[f] | os.O_NONBLOCK)
+                               except EnvironmentError, e:
+                                       if e.errno != errno.EAGAIN:
+                                               raise
+                                       del e
+                                       # The EAGAIN error signals eof on FreeBSD.
+                                       eof = True
+                                       break
                                buf = array.array('B')
                                try:
                                        buf.fromfile(f, buffsize)